DIP 36: Rvalue References
Timon Gehr
timon.gehr at gmx.ch
Sun Apr 21 10:39:01 PDT 2013
On 04/21/2013 02:51 AM, Manu wrote:
> On 21 April 2013 06:51, Timon Gehr <timon.gehr at gmx.ch
> <mailto:timon.gehr at gmx.ch>> wrote:
>
> On 04/20/2013 05:56 PM, Dicebot wrote:
>
> You miss quite an important point - DIP36 does not add new
> feature. It
> partially defines existing feature (scope) to replace an
> existing but
> broken solution (auto ref). Nothing new is really added to the
> language,
> only existing stuff better defined.
>
>
> _New meaning_ is assigned to existing grammar whose original purpose
> is at most loosely related to the _new_ features.
>
> I do not think that making 'scope' indicate an rvalue reference is
> particularly future proof.
>
>
> That's not what scope does. Scope promises that the variables will not
> escape the scope.
That is the intention, but this formulation is awfully imprecise. Hence
nothing has been implemented.
void foo(scope ref int x){ ... }
void foo(scope int* x){ ... }
void foo(scope ref int* x){ ... }
// ???
struct S{
scope S* x; // ???
}
> And as such, just happens to make passing a temporary
> by ref safe.
> ...
But this is not about safety! Passing an rvalue by ref is disallowed
even in @system code. Hence 'scope' is assigned a meaning different from
its intention. The DIP also aims to add more special behaviour to
built-in literals.
More information about the Digitalmars-d
mailing list