auto ref is on the docket

Namespace via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 22 13:50:21 PDT 2015


On Monday, 22 June 2015 at 20:42:58 UTC, Daniel N wrote:
> On Monday, 22 June 2015 at 05:25:57 UTC, Walter Bright wrote:
>> The idea is that fun(5) would be lowered to:
>>
>>    auto tmp = 5;
>>    fun(tmp);
>>
>> But when talking to Andrei I didn't realize that it would be 
>> subtly different behavior than 'auto ref' for template 
>> functions, which makes me concerned that this is not a good 
>> idea.
>
> Considering we already have working 'Sealed references', why 
> not simply allow rvalues for plain ref?
>
> Bonus: No risk of mixup with template auto ref after 
> refactoring etc.
> Save auto for other potential future use.

That would be horrible. How would you distinguish between lvalues 
and rvalues? What if you want to store a pointer to an lvalue? If 
ref accept both you cannot do that.


More information about the Digitalmars-d mailing list