My thoughts & tries with rvalue references

Dicebot m.strashun at gmail.com
Fri Apr 5 01:44:29 PDT 2013


On Friday, 5 April 2013 at 08:35:03 UTC, Namespace wrote:
> On Friday, 5 April 2013 at 07:48:38 UTC, Dicebot wrote:
>> On Thursday, 4 April 2013 at 16:25:52 UTC, kenji hara wrote:
>>> I also think writing DIP would be better.
>>> ...
>>
>> Btw, Kenji, what do you think about redefining "in" to "const 
>> scope ref" and allowing compiler to chose how variable exactly 
>> is passed ("auto ref" with no template bloat)? Within those 
>> restrictions plain values should be indistinguishable from 
>> const rvalue refs.
>>
>> Will make "in" also much more meaningful as a separate entity.
>
> To change "in" from "const scope" to "const scope ref" is IMO a 
> bad idea. It will break code and it's not intuitive.
> In my opinion we should use "ref" in combination with something 
> else (in this case "scope").
> But that is my personal opinion.

How so? It does not break anything, as all "const scope" cases 
can be processed with "const scope ref", in fact, compiler should 
be allowed to degrade first to latter. Regarding meaning - if 
"scope ref" means permissive rvalues (mutable ones), then "const 
scope ref" means closer match for C++ "const &" - constant 
references that can't escape scope. I actually have an impression 
you do really want exactly "const scope ref" considering frequent 
references to C++.

Tricky part as far as I can see is ABI - one needs to be able to 
accept both value and ref parameters within same function 
signature. Possible but may be too hacky to implement.


More information about the Digitalmars-d mailing list