rvalue references

Namespace rswhite4 at googlemail.com
Tue Apr 23 00:07:35 PDT 2013


On Tuesday, 23 April 2013 at 03:30:35 UTC, Walter Bright wrote:
> Previous discussions:
>
> http://forum.dlang.org/thread/4F84D6DD.5090405@digitalmars.com#post-4F84D6DD.5090405:40digitalmars.com
>
> http://d.puremagic.com/issues/show_bug.cgi?id=9238

I still like the Idea of DIP 36 (http://wiki.dlang.org/DIP36) 
with scope ref / in ref. On this link we have also collected 
several other suggested syntaxes.
But maybe we should discuss first, if auto ref could work for 
non-templates.
This would mean that
1. auto ref generate code bloat for non-templates (doubled the 
function 2^n times)
or
2. auto ref works like scope ref would do (create a temporary 
lvalue and pass this to the function). But that would mean that 
auto ref work differently for templates and non-templates (maybe 
a problem?). If we choose this we should also discuss about the 
lifetime of the temporary:
----
foo(auto ref A a) { }

foo(A());
// should then converted to
{
     A __temp = A();
     foo(__temp); // after this, __temp is destroyed
}
----
or
3. the compiler choose if an argument should be passed by ref, by 
value or should be moved.
For example:
----
A a = A(42);
foo(a); // by ref
foo(A(23)); // move
----


More information about the Digitalmars-d mailing list