4 ms·
> `Vector int` is the more logical syntax. This introduces several parser ambiguities, esp. related to nested template types or types with multiple parameters.
by majewsky 6y ago
> `Vector int` is the more logical syntax.
This introduces several parser ambiguities, esp. related to nested template types or types with multiple parameters. For instance, does `Foo Bar Baz` read as `Foo(Bar, Baz)` or `Foo(Bar(Baz))`?
- Animats 6y agoRight. For consistency, the old built-in generics should be written var v chan(int) var m map(keytype,datatype) instead of var v chan int var m map[keytype]datatype but, for backwards compatibility, that probably won't happen. Thus, cruft. Map was always a bit too special in Go. Channels really are special; the compiler knows quite a bit about channels, what with "select", "case", and "go" keywords and their machinery. But maps are just a built in library object.
- dvirsky 6y agoI wonder if at least they will add this as an additional way to define them and deprecate the old ones without disabling them.
- nyanpasu64 6y agoIf you want a dynamically sized vector pointing to a datatype, I think `Vector [] Value` is most "semantically meaningful". And if you want to define your own map, `Map [Key] Value` is most self-explanatory... now that I look at it, I'm starting to feel that this introduces too many special cases and complexity into generic syntax to be useful for the actual language parser. I might stick with that in documentation/comments instead.