The syntax is &type{...}. &42 does not match this syntax. What Jan was
describing is specific to that syntax, not to the use of & in general; in
fact let's try it for &x:

tmp := x
&tmp

This gives a very different and not useful value for &x. &T{...} is an
exceptional syntactic sugar for grabbing the address of a compound value.
It doesn't make much sense to generalize this syntactic sugar to other
values.

On Mon, Jul 25, 2016 at 9:57 AM Konstantin Khomoutov <
flatw...@users.sourceforge.net> wrote:

> On Mon, 25 Jul 2016 15:54:02 +0000
> Jan Mercl <0xj...@gmail.com> wrote:
>
> > > If T{} is like 42, why “(&T{})" is legal?
> >
> > Because
> >
> >         &T{...}
> >
> > is syntactic sugar for
> >
> >         tmp := T{...} // behind the scenes
> >         &tmp
> >
> > and &tmp is an okay receiver in the OP.
>
> But by the same logic one could state that
>
>   &42
>
> should be allowed because behind the scenes it could have been
>
>   tmp := 42
>   &tmp
>
> So, why this is not allowed for simple types?
>
> --
> 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