Re: [go-nuts] New identifiers and selectors in short variable declarations

2018-01-10 Thread Jan Mercl
On Tue, Jan 9, 2018 at 10:08 PM Jim Bishopp wrote: > Has there ever been a discussion about allowing new identifiers and selectors in short variable declarations? FTR: There are other things that are legal on the LHS of an assignment, but not in the short variable

Re: [go-nuts] New identifiers and selectors in short variable declarations

2018-01-09 Thread matthewjuran
This works: b, a := 1, struct{ x int }{2} But this doesn’t: var a struct{ x int } b, a.x := Returns1And2() But this does: var a struct{ x int } var b int b, a.x = Returns1And2() And this does: var a int b, a := Returns1And2() Matt On Tuesday, January 9, 2018 at 5:59:49 PM UTC-6, Kevin

Re: [go-nuts] New identifiers and selectors in short variable declarations

2018-01-09 Thread 'Kevin Malachowski' via golang-nuts
It is not a new declaration, it is definitely an assignment. This can be determined because (in Go) a new declaration has effects when closing over variables: https://play.golang.org/p/a_IZdOWeqYf (ignore the obvious race condition; it works the same but looks uglier with the requisite locks:

Re: [go-nuts] New identifiers and selectors in short variable declarations

2018-01-09 Thread Ayan George
On 01/09/2018 04:45 PM, Ian Lance Taylor wrote: > On Tue, Jan 9, 2018 at 1:02 PM, Jim Bishopp > wrote: >> >> Has there ever been a discussion about allowing new identifiers and >> selectors in short variable declarations? >> >> var a struct { x int } b, a.x := 1, 2 >>

Re: [go-nuts] New identifiers and selectors in short variable declarations

2018-01-09 Thread Ian Lance Taylor
On Tue, Jan 9, 2018 at 1:02 PM, Jim Bishopp wrote: > > Has there ever been a discussion about allowing new identifiers and > selectors in short variable declarations? > > var a struct { x int } > b, a.x := 1, 2 > > ERROR: expected identifier on left side of := That idea

[go-nuts] New identifiers and selectors in short variable declarations

2018-01-09 Thread Jim Bishopp
Has there ever been a discussion about allowing new identifiers *and selectors *in short variable declarations? var a struct { x int } b, a.x := 1, 2 ERROR: expected identifier on left side of := -- You received this message because you are subscribed to the Google Groups "golang-nuts"