Conversation

The parens for the type parameters is the one thing Go got right in the entire language.
Quote Tweet
Replying to @omengue @golang and @ianlancetaylor
My main concern is the syntax. Parentheses for type parameters are hard to distinguish from parentheses value parameters. The FAQ mentions that F<T> and F[T] have been considered and rejected. The pain will be on the users to "to keep the parser simple".
2
7
it does mean that you can now have a total of four sets of parens in a function def: func (type T) (s Foo*) Bar(arg1 Baz, arg2 Baz2) (bool, Quux)
1
3
My first instinct is to say "but those aren't the same thing!" but if it's a feature-for-feature trade I'd happily give up interfaces for tagged unions. Can always use records with functions in them instead, they're not even that bad to use.
2
I thought the issue was more that they started out with the assumption that everything needed a default value. Anyway, that means it's hard to have a default for tagged unions (which should have given them a hint that defaults for everything is kinda ick, but egh).
2
1
There are some practical advantages to having a fixed initial value like zero... mostly related to allocator optimizations, AFAIK. But of course if those aren't actually reasonable values and always get changed in practice these optimizations are worthless.
2
1
Show replies