What is the meaning of this?

Zdenek Tronicek tronicek at fit.cvut.cz
Tue Feb 2 12:18:15 PST 2010


Joshua Bloch napsal(a):
> I believe the notion of "transparency" that some are arguing for
> conflicts with basic design principles of Java in a way that's likely to
> cause trouble. It glosses over the identity of a lambda without
> eliminating it entirely.

This interests me. Could you eventually elaborate on it?

Z.
-- 
Zdenek Tronicek
FIT CTU in Prague



>
> On Thu, Jan 28, 2010 at 10:56 PM, Zdenek Tronicek
> <tronicek at fit.cvut.cz>wrote:
>
>> Joshua Bloch napsal(a):
>> > More importantly, evaluating this in the enclosing context is
>> > perverse in Java. In every context where this is legal today, it
>> refers
>> to
>> > the innermost instance. It would be inconsistent to do otherwise for
>> > lambdas, and we would need a very good reason to knowingly create this
>> > inconsistency. I haven't heard any such reason. There is, however, a
>> real
>> > disadvantage to making this refer to the enclosing instance: people
>> will
>> > streamline existing code that uses anonymous classes, and could easily
>> end
>> > up with code that doesn't compile or (worse) compiles but misbehaves
>> > because
>> > the meaning of this would be different in the new (lambda) and old
>> > (anonymous class) code.
>>
>> There is a substantial difference between your view and view of
>> "transparency guys". You view closures as a concise notation of
>> anonymous
>> classes and then you, naturally, expect that 'this' refers to the
>> instance
>> of such class. "Transparency guys" view closures as blocks of code or
>> functions. Then, 'this' should refer to the enclosing instance.
>> So, the discussion is not about 'this', but about what the closures will
>> be.
>>
>> Z.
>> --
>> Zdenek Tronicek
>> FIT CTU in Prague
>>
>>
>



More information about the lambda-dev mailing list