Delegate is left with a destroyed stack object

David Nadlinger code at klickverbot.at
Tue Oct 29 14:41:45 PDT 2013


On Tuesday, 29 October 2013 at 21:37:43 UTC, Ali Çehreli wrote:
> To add to that, Maxim Fomin notes in the D.learn forum that 
> there are the following conflicting requirements:
>
> 1) need to allocate struct into heap due to lambda
>
> 2) need to put dtor invocation in the end as usual.
>
> The first one is supported by the closure spec. The second one 
> is the well-know struct destruction upon leaving a scope.

Closures follow the infinite lifetime model – the struct scope is 
never left, if you want.

This is not exactly a new scenario, destructors on new'd structs 
aren't called either (unless you manually destroy them).

David


More information about the Digitalmars-d mailing list