Binding temporaries to ref [WAS: I close BIP27. I won't be pursuing BIPs anymore]

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 22 18:08:03 PDT 2016


On Saturday, 22 October 2016 at 22:05:54 UTC, Jonathan M Davis 
wrote:
> On Saturday, October 22, 2016 23:13:28 Timon Gehr via 
> Digitalmars-d wrote:
>> I'm ready to participate (but I can't invest too much time at 
>> the moment). Are we going with @rvalue ref?
>
> That would certainly be my preference - at least out of what's 
> been discussed thus far.
>
> - Jonathan M Davis

With move semantics in mind, I'm wondering if there may be a 
better word.

Currently in D, IIRC, explicit moving can be done through 
by-value arguments. If you want to move explicitly from an 
lvalue, you can use D's std.move(lvalue). The downside is an 
extra blit/init into the rvalue that's returned by std.move. 
Then, the function that takes the rvalue may blit again in order 
to store the contents that are being moved in.

As an alternative, non-const '@rvalue ref param' could be 
used...but would it be clear enough to people(seeing non-const 
@rvalue) that the contents of the argument could potentially be 
consumed/moved-from?




More information about the Digitalmars-d mailing list