[dmd-beta] rvalue references
Jonathan M Davis
jmdavisProg at gmx.com
Tue Apr 10 20:33:31 PDT 2012
On Tuesday, April 10, 2012 20:29:40 Walter Bright wrote:
> On 4/10/2012 8:11 PM, Jonathan M Davis wrote:
> > On Wednesday, April 11, 2012 10:23:44 kenji hara wrote:
> >> Agreed. Introducing *rvalue reference* requires such changes for
> >> consistency. But, again, keep all literals rvalue, please.
> >
> > Indeed. It's incredibly inconsistent for struct literals to be lvalues.
> > Literals should always be rvalues. Allowing references to them with
> > something like const& like in C++ is of value, but that's of value with
> > _all_ temporaries. struct literals should not be treated specially from
> > other literals or temporaries. Having
> >
> > void func(ref S s) {}
> > S foo() {}
> > func(S(1)); //succeeds
> > func(foo()); //fails
> >
> > is atrocious. It's incredibly inconsistent and confusing. S(1) should
> > treated identically as the return value of foo().
>
> These will both work under my proposal.
With plain ref? const ref is one thing, but I'd be very nervous about letting
ref take a temporary.
- Jonathan M Davis
More information about the dmd-beta
mailing list