I don't like the syntax &int{0} because int is not a compound type, but
&int(0) seems reasonable syntax to me. I do think there is an irregularity
in the language here:

type Int struct{i int}
anInt := Int{5}
p1 := &Int{5}     // works
p2 := &anInt.i    // works
p3 := &Int{5}.i   // compiler error "cannot take the address of Int
literal.i"

So we can take the address of an Int literal (suggesting that struct
literals are addressable), and we can take the address of a field of an
addressable struct, but we can't take the address of a field of a struct
literal?

On Fri, Oct 21, 2016 at 1:44 PM Nate Finch <nate.fi...@gmail.com> wrote:

Perhaps regular was the wrong choice of phrasing.  From an end-user's
perspective, it makes the language more consistent, rather than having
&T{v} work for some of the more complex values of T, but not for the more
simple values of T.

On Fri, Oct 21, 2016 at 3:59 PM Jan Mercl <0xj...@gmail.com> wrote:

On Fri, Oct 21, 2016 at 9:20 PM Nate Finch <nate.fi...@gmail.com> wrote:

> And, I would argue, it actually makes the language slightly more regular,
since now &T{v} works for just about everything (possibly everything?).

Taking the address of an addressable thing is the regular proper. Taking
address of a non-addressable things, even though practical, is syntactic
sugar. Enlarging the surface of the later irregularity cannot make anything
more regular.

-- 

-j

-- 
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.
For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to