On Wed, Jul 15, 2020 at 8:25 AM Michael Jones <[email protected]>
wrote:
> nice. "gen" here is akin to the existing forward declaration of recursive
> inner functions. it says, "you are about to see something special and you
> need to know *this* about it."
>
>
The real name is "forall", and it presents a binding site of a type-level
parameter.
forall T, type pair struct { a, b T }
This would bring the notation close to Coq.
Other solutions:
Haskell used capitalized types, String, Bool, Int, ... and lowercase names
are parameters, so if you used e.g., 't' in the above, it would implicitly
be a type parameter. This is out in Go, due to the capitalization already
being used.
OCaml and SML uses a quote prefix to notion the parameter, e.g., the above
would be written
type 'a pair = { a : 'a; b : 'a }
and likewise
type 'a option = None | Some of 'a
Yet the current proposal is fine! I think keeping the parser simple is an
important goal. Solutions which have whitespace-aware parsing are not good
solutions, I think, because they break that the graphical characters are
the only which have meaning. They also break in subtle ways when you
copy-paste code, some times without parse error but different semantics.
Solutions based on < and > irks me for the lookahead needed in the parser.
That notation was popularized by C++, and I think the argument that we
should just copy it is weak. Go already cleaned up lots of small mistakes
in the C-like syntax. If we can clean up type-level parametrization in
addition, it would be really nice. We can't get any language evolution if
people keep being syntax-conservative. New syntax doesn't automatically
apply a gaussian blur to your eyes.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/CAGrdgiWHFwjVrHGTwZRhk5EfzfZ3Xdf8oBHmE0ZWo-FJqhr82A%40mail.gmail.com.