On Sun, Mar 29, 2015 at 1:00 AM, Joshua Liebow-Feeser <
he...@synful.io> wrote:
>
> I've tried searching for similar proposals, since I figured they probably
> existed, but couldn't find any. If there are any, just reply with a link and
> I'll shut up :)
>
> My proposal is this. I like the &T{} syntax for struct initialization, and I
> don't see why it shouldn't be supported for all types. After all, for any
> arbitrary T, the following is valid:
>
> t := new(T)
> *t = <literal> // such as &T{}
>
> Thus, the &<literal> syntax could work for any type.
This has been discussed before, along with other permutations of
composite literals, new, and make. I don't think anybody is really
happy with permitting expressions like &1; treating that as allocating
new memory and coying 1 into it makes &1 very different from &v. It
also means that &x[i] is very different depending on whether x is a
slice or a map, and that is a kind of confusion we really don't want.
The current composite literal pointer syntax is arguably misleading,
and should probably have been (*T){vals}.
Ian