How Nested Functions Work, part 1

Jarrett Billingsley jarrett.billingsley at gmail.com
Sun Aug 30 20:19:03 PDT 2009


On Sun, Aug 30, 2009 at 10:54 PM, Jeremie Pelletier<jeremiep at gmail.com> wrote:
>
> I need to try that out, its most likely a bug since 'in' means 'const scope' now.
>
> Check my second code bit, the delegate is declared as scope and it doesn't optimize, maybe the compiler only checks if the closure is being dereferenced and if so switches to memory storage instead of stack storage without checking the storage class of the closure's delegate. And even without 'scope' in this case the compiler could detect that the delegate doesn't leave the function scope and optimize away.

The compiler currently doesn't do anything with local delegates
declared with 'scope'. It only seems to do anything special if 'scope'
is used as a parameter storage class.

> Better yet, allow forward references for nested functions. The need to assign closures to delegates to get a nested function is so C# ;)

Oh indeed ;)



More information about the Digitalmars-d mailing list