Const ref and rvalues again...

Timon Gehr timon.gehr at gmx.ch
Fri Oct 19 06:00:51 PDT 2012


On 10/19/2012 09:53 AM, Jacob Carlborg wrote:
> On 2012-10-19 04:48, Timon Gehr wrote:
>
>> Then how to specify that the value of x cannot be escaped?
>> I'm in favour of doing it the other way round and disallow escaping of
>> ref parameters without an unsafe cast.
>
> "scope" is supposed to be used to prevent this.
>

Sure, but how?

void goo(scope int* x){
     global0 = x; // should clearly be disallowed
}

void foo(scope ref int*** x){
     global1 = &x; // ?
     global2 = x;  // ?
     global3 = *x; // ?
     globall4 = **x; // ?
}

Maybe we need this:

void foo(scope ref int*** x);   // ?
void foo(ref int(***)scope  x); // no escaping of x, *x, **x
void foo(ref int*(**)scope x);  // may escape **x
void foo(ref int**(*)scope x);  // may escape *x, **x

What about &x?


More information about the Digitalmars-d mailing list