[go-nuts] Re: [generics] Generic functions calls little confusing to readers

2020-06-17 Thread google via golang-nuts
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

Re: [go-nuts] Re: [generics] Generic functions calls little confusing to readers

2020-06-17 Thread Harald Weidner
Hello, > There is an existing case which doesn't seem to bother many people: > > foo.Bar() > > Is this calling function Bar in package foo, or method Bar on variable > foo? It could also be a call of a function within the struct value foo. foo.Bar(baz) can have at least four meanings: 1. calli

[go-nuts] Re: [generics] Generic functions calls little confusing to readers

2020-06-17 Thread Brian Candler
Also, type arguments to generic function calls are *optional*: https://go2goplay.golang.org/p/w-q65tL5wh- Therefore, when looking at a foo(bar)(baz), you have to know whether (bar) is a value or a type, which requires scanning the code to find the definition of 'bar' in this scope or nearest enc

[go-nuts] Re: [generics] Generic functions calls little confusing to readers

2020-06-16 Thread Zach Easey
Interesting find, I would expect type parameter declarations to be limited to interfaces. On Tuesday, June 16, 2020 at 2:54:02 PM UTC-7, Alexander Morozov wrote: > > For example consider this example https://play.golang.org/p/rfccpBoFIJN > There is no generics involved, but for person reading the