Here's a proposal for a syntactic modification to the draft proposal that removes explicit type parameters from functions, and just uses generic types directly (e.g., the new interface types): https://github.com/golang/go/issues/39669
This would go a long way toward simplifying the syntax and avoiding most of the worst issues with parens, while otherwise being essentially identical to the draft proposal. Here's a sample: // draft proposal func StrAndPrint(type L interface{}, T Stringer)(labels []L, vals []T) { ... } // GT proposal func StrAndPrint(labels []type, vals []Stringer) { ... } you just use the generic types like any other existing types! `type` can be used for an unconstrained generic type -- otherwise you use the generic interface type for constrained types. - Randy > On Jun 17, 2020, at 4:45 PM, google via golang-nuts > <golang-nuts@googlegroups.com> wrote: > > On Wednesday, 17 June 2020 07:54:02 UTC+10, Alexander Morozov wrote: > I wonder how could we avoid this confusion (apart from using different > brackets :)). > > I know the brackets discussion has been had before, and that there are some > technical, and non-technical reasons why parentheses were settled on, but > this really illustrates the limitations of relying on a single delimiter for > everything. Even in function declarations, where it's most clear what's > intended, there is a significant cognitive load placed on the reader to > determine what's happening, possibly involving backtracking to a previous set > of parens. I think underestimating the impact of the syntax on reading > comprehension would be a grave mistake, and I strongly believe that the > proliferation of parens hurts here. > > This second draft removes some other concerns that I had with the contracts > design, but this syntax issue has stuck out to me as problematic since the > start, and I can't shake it. > > -- > 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 golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/f1699384-f487-44a4-b8d6-17950b2c4913o%40googlegroups.com. -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/E5F0CAFF-3086-4345-A4CD-840A673B21AE%40gmail.com.