this should not refer to the lambda

Alex Blewitt alex.blewitt at gmail.com
Sun Feb 21 14:30:02 PST 2010


On 21 Feb 2010, at 22:00, Rémi Forax wrote:

> Le 21/02/2010 20:11, Alex Blewitt a écrit :
>>> Alex, try to compile:
>>> int a =a;
>>> and take a look to the error message.
>>>     
>> Test.java:2: illegal forward reference
>> int a=a;
>>       ^
>> 
>> That's the point - it's an illegal reference. Yet, were 'this' used to
>> describe only the enclosing object instance (and not the lambda
>> instance), you wouldn't be able to do recursive lambdas.
>>   
> 
> The message is not something like "can't find symbol".
> The compiler knows what 'a' means.

Knows, and disallows. That's why I don't believe recursive lambdas, defined in the same way, should be allowed either. If that's the case, then the decision as to what 'this' means directly affects whether recursive lambdas are possible.

Alex


More information about the lambda-dev mailing list