[dmd-beta] rvalue references

Walter Bright walter at digitalmars.com
Tue Apr 10 20:29:40 PDT 2012



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.


More information about the dmd-beta mailing list