What is the meaning of this?
Neal Gafter
neal at gafter.com
Wed Feb 3 11:52:06 PST 2010
On Wed, Feb 3, 2010 at 11:11 AM, Osvaldo Doederlein <opinali at gmail.com> wrote:
>> Lambdas that must be represented as instances but don't capture enclosing
>>> state should not be forced to be unique instances.
> 2010/2/3 Joshua Bloch <jjb at google.com>
>> You'll get no argument here! And I don't see this having any bearing on the
>> meaning of "this." I see a lambda expression as a sort of a static factory.
>> If you evaluate it ten times, it's fine if all ten evaluations produce the
>> same object, in which case I believe that this should return the same value
>> in all ten.
> This agreement makes me very happy. This was subject to debate in some
> emails.
There are a few relationships between this issue and the meaning of "this".
To take one, this agreed-upon position conflicts with SAM classes,
because the execution of the constructor is visible. The
specification must clearly detail the handling of exceptions thrown by
the constructor in the compile-time and run-time semantics of the
lambda conversion, and I don't see any alternative but to specify them
occurring at the point of the conversion. SAM interfaces don't have
this issue because they don't have constructors. But for SAM
interfaces, while there is utility to lexically scoped "this", the
proposed benefit of "this" referring to the function type (it can be
cast to the SAM type) is de minimis.
More information about the lambda-dev
mailing list