The future of lambda delegates
Walter Bright
newshound at digitalmars.com
Wed Aug 16 18:28:57 PDT 2006
Sean Kelly wrote:
> The archive routine would check dg's stack frame to see if a heap copy
> of the frame exists (assume it's stored as a pointer at this[0]). If
> not then memory is allocated, the pointer is set, the frame is copied,
> and dg's 'this' pointer is updated to refer to the dynamic frame.
> Returning a delegate from a function would just implicitly call this
> 'archive' routine. This could still cause errors, as a programmer may
> forget to call "dg.archive" before storing the delegate, but I think
> this is an acceptable risk and is far better than having the compiler
> try to "figure out" whether such a dynamic allocation is needed. It
> also seems fairly easy to implement compared to the alternatives, and
> offering the feature through a property method would eliminate the need
> for a new keyword.
It's not the new keyword that's the problem - it's the fact that the
programmer has to identify the delegate as special.
More information about the Digitalmars-d
mailing list