My thoughts & tries with rvalue references

Zach the Mystic reachzach at gggggmail.com
Tue Apr 2 18:20:44 PDT 2013


On Wednesday, 3 April 2013 at 01:19:18 UTC, Zach the Mystic wrote:
> On Tuesday, 2 April 2013 at 15:08:20 UTC, Namespace wrote:
>> On Saturday, 30 March 2013 at 12:00:32 UTC, Namespace wrote:
>>> As far as I studied the code, something like @ref isn't 
>>> possible, because ref is already a keyword. Except as 
>>> Pseudo-property. But this is a combination of '@' and 'ref' 
>>> so that both, '@ref' and '@ ref' would be valid.
>>> I still like the idea of '&A'.
>>
>> I have to disagree with me here.
>> Thanks to this thread 
>> (http://forum.dlang.org/thread/ohjdraaizvwiczifwrlk@forum.dlang.org) 
>> I know now that after the '@' can be an unlimited number of 
>> white spaces.
>> Hence my previous speculation that I would have implemented 
>> something wrong is wrong. So is something like '@ref' possible 
>> and already implemented, as you can see here: 
>> https://github.com/Dgame/dmd/tree/rvalue_property
>>
>> I think this is probably the end result of my little journey. 
>> Any objections?
>
> '@ref' is actually my least favorite choice. Of all presented, 
> my two favorites are
>
> void func(ref& int a) {}
>
> void func(@val ref int a) {}
>
> Hara Kenji's comment about 'scope ref' also raises the issue of 
> just how subtle is the difference between this proposed feature 
> and what 'auto ref' does in templates. Correct me if I'm wrong, 
> but 'ref&' is proposed to have the compiler create a temporary 
> at the call site and pass it as a reference.
>
> ref int func1(ref& int a) { return a; }
>
> // Example:
>
> int func2(ref int b) { return a; }
> int x = func2(func1(3));

s/ref int b/ref int a/


More information about the Digitalmars-d mailing list