auto ref is on the docket

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 22 18:07:16 PDT 2015


On Monday, 22 June 2015 at 21:30:45 UTC, Daniel N wrote:
> On Monday, 22 June 2015 at 20:56:12 UTC, Jonathan M Davis wrote:
>> won't mutate the argument, but if you allow it with ref in 
>> general, then you stand no chance of being able to look at a 
>> function signature and deduce whether the function intends to 
>> mutate an argument or not.
>>
>> - Jonathan M Davis
>
> It's no worse than auto ref. It's only by convention that auto 
> ref functions doesn't mutate, at least I follow that 
> convention, but when looking at someone else's function, all 
> bets are off.

No, you can't guarantee that an auto ref parameter won't be 
mutated, but auto ref clearly indicates that you intend to accept 
both lvalues and rvalues, meaning that it would be stupid to be 
writing the function with the idea that you would be passing in 
an argument which would be mutated. ref on the other hand clearly 
indicates the intention to mutate the argument.

- Jonathan M Davis


More information about the Digitalmars-d mailing list