scope in function argument

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 23 10:11:47 PDT 2015


On Wednesday, 23 September 2015 at 17:09:40 UTC, Freddy wrote:
> What does it mean when there is a scope in a function argument.

That you are not supposed to let that reference escape the 
function scope. The compiler does little verification of this 
right now, but may optimize on that assumption (notably, scope 
delegates will not be copied to the heap right now).

In the future, it may become an error to allow them to escape.

int* b;

void func(scope int* a) {
    b = a; // you made a escape the function scope, undefined 
behavior results
}



More information about the Digitalmars-d-learn mailing list