What is the meaning of this?
Neal Gafter
neal at gafter.com
Thu Jan 28 11:31:30 PST 2010
On Thu, Jan 28, 2010 at 11:19 AM, Joshua Bloch <jjb at google.com> wrote:
> Entirely banning the use of this in lambada expressions is a very bad idea.
> It amounts to throwing out the baby with the bath water. If you need to get
> your hands on the function object created by a lambda expression, but
> this doesn't
> provide it, you're out of luck. There is no general-purpose workaround.
Yes there is, and people have been using it for years. It's called
the anonymous inner class. As far as I know there is no proposal to
remove it from the language.
> Evaluating this as if it were used in the context enclosing the lambda
> expression is a gratuitous inconsistency that violates the principle of
> least astonishment.
Perhaps you haven't noticed how many people have been astonished by
the treatment of "this" in the current draft, or how few people have
been astonished by the treatment of "this" in all the other
object-oriented languages that have lambda expressions.
More information about the lambda-dev
mailing list