The future of lambda delegates

Walter Bright newshound at digitalmars.com
Wed Aug 16 18:24:40 PDT 2006


BCS wrote:
> Walter Bright wrote:
>> BCS wrote:
>>
>>> BTW how do you construct a delegate literal inside of a class method 
>>> that uses "this" as it's context, rather than the frame pointer?
>>>
>>> class Foo
>>> {
>>>     int i;
>>>     int delegate() fig(){ return {return i;}; }
>>
>>
>> It uses the frame pointer of fig() to access fig()'s this. Of course, 
>> though, this will currently fail because fig() is exited before the 
>> delegate is called.
>>
> 
> a.k.a. It can't be done?

It's the same problem as elsewhere returning a delegate that accesses 
the frame of the function that returns it.



More information about the Digitalmars-d mailing list