DIP69 - Implement scope for escape proof references

zeljkog via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 8 09:18:54 PST 2014


On 05.12.14 21:55, Walter Bright wrote:
> 
> It means that this code will be safe:
> 
>     void foo(scope int* p);
> 
>     p = malloc(n);
>     foo(p);
>     free(p);
> 
> The rest is all the nuts and bolts of making that work.
> 

If it is main goal, opposite looks more natural.

void foo(int* p);
void foo1(escape int* p);
 
p = malloc(n);
p1 = malloc(n);
foo(p);
free(p);  // OK
foo1(p1);
free(p1);  // no
     



More information about the Digitalmars-d mailing list