Syntactic ambiguity in generic type declarations.
zenhack opened this issue · comments
This is another issue that was raised in the go 2 generics draft design, and was cited as the reason not to use square brackets for type parameters:
To summarize: what is the meaning of type Foo [T] int
? is it an a generic type which does not actually use its type parameter, or is it an array with size T (where T would have to be a constant)?
Right now fo seems to treat it as an array if T is in scope, or a type parameter otherwise -- which is confusing, and I really don't like that it needs a symbol table to disambiguate.
@alanfo proposed using this syntax instead: type Foo[type T] int
The original gist:
@zenhack thank you for pointing this out. I'm well aware of the ambiguities introduced by the current syntax and I agree that it is not perfect. However, in practice it has not been a big issue so far and I will be focusing on other features/fixes in the near future.
Tackling #2 and improving interop with vanilla Go is my main focus for now.
By the way there has been some discussion about alternative syntax in #10. I would like to keep all syntax-related proposals/feedback there if possible to make it easier to get a wholistic view of the topic. I'm closing this issue, but feel free to continue the discussion in #10.
I agree this isn't top priority. Moving it to #10 makes sense.