DIP 1016--ref T accepts r-values--Community Review Round 1

aliak something at something.com
Fri Jul 20 16:42:54 UTC 2018


On Friday, 20 July 2018 at 13:21:11 UTC, Jonathan M Davis wrote:
> On Friday, July 20, 2018 05:16:53 Mike Parker via Digitalmars-d 
> wrote:
>> [...]
>
> I am completely against allowing ref to accept rvalues without 
> some sort of attribute indicating that it should be allowed to 
> (e.g. @rvalue ref). Allowing ref to accept rvalues goes 
> completely against the idea that ref is for passing an object 
> so that it can be mutated and have its result affect the 
> caller. With this DIP, we'd likely start seeing folks using ref 
> all over the place even when it has nothing to do with having 
> the function mutating its arguments, and that's not only 
> error-prone, but it obfuscates what ref was originally intended 
> for.
>
> [...]

I kinda agree with this, just not so strongly I think.

But as for a UDA, maybe @implicit from the copy constructor DIP 
can be reused here?

void f(@implicit ref A a) {}

On a side note, I'm not familiar with the talks that've gone 
around the keyword "in", and I see there's a deprecation issue on 
bugzilla [1]. Can "in" be added here? "in ref" or just repurposed 
completely?

Cheers,
- Ali

[1] https://issues.dlang.org/show_bug.cgi?id=18604


More information about the Digitalmars-d mailing list