delegates & GC allocations

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 20 08:07:44 PDT 2014


On Wednesday, 20 August 2014 at 14:54:31 UTC, ketmar via 
Digitalmars-d-learn wrote:
> On Wed, 20 Aug 2014 10:44:38 -0400
> Etienne via Digitalmars-d-learn 
> <digitalmars-d-learn at puremagic.com>
> wrote:
>
> and this is not delegate, this is just nested function.

non-static nested functions are effectively delegates as it needs 
a context pointer to parent stack frame. However, not every 
delegate is a closure - heap allocation of the context happens 
only if delegate leaves the scope it refers to (via return value 
or by being passed as an argument to external function)


More information about the Digitalmars-d-learn mailing list