The future of lambda delegates

Oskar Linde olREM at OVEnada.kth.se
Wed Aug 16 12:39:53 PDT 2006


kris wrote:

> Yeah, this is a serious trap for the unwary and, unfortunately,
> prohibits the use of such delegates in the one place where the elegance
> would be most notable: as gui callbacks, per your example. As you say,
> the way around it (currently) is to create a class to house the 'scope'
> content, or otherwise refer to it. That's unweildy, even with
> anonymous-class syntax.
> 
> If, as you suggest, D had some means to indicate that the scope should
> be placed on the heap instead of the stack, it would resolve the concern
> nicely. Perhaps that indication might be lambda syntax itself? For
> example, in C# the lambda indicator is the symbol '=>'

I don't think any special syntax is needed. I believe the compiler could be
able to automatically identify whether a function may have escaping
delegates referring to local variables. 

/Oskar




More information about the Digitalmars-d mailing list