Scope storage class
Steven Schveighoffer
schveiguy at yahoo.com
Thu Nov 27 07:04:27 PST 2008
"Walter Bright" wrote
> Jarrett Billingsley wrote:
>> So my suspicion is correct, then? That is:
>>
>> scope int delegate() b;
>> b = { ... };
>>
>> Will allocate on the heap?
>
> Yes. The scope for delegates takes effect as a parameter storage class,
> not a local variable storage class. The reason is because it is the called
> function that decides what it's going to do with the delegate.
Why? It would be useful to allow local scope delegates.
The compiler can just forbid passing the delegate to a function which does
not declare its parameter as scope. I assume the compiler knows a variable
is scope since it must prevent escape of the delegate, no? So just use that
information. I thought that was the point of all this...
-Steve
More information about the Digitalmars-d-announce
mailing list