this should not refer to the lambda
alex.blewitt at gmail.com
Sun Feb 21 12:29:13 PST 2010
On Sun, Feb 21, 2010 at 7:48 PM, Neal Gafter <neal at gafter.com> wrote:
> On Sun, Feb 21, 2010 at 11:11 AM, Alex Blewitt <alex.blewitt at gmail.com>
>> 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.
> We've already shown both that the need for this is rare and that there are a
> number of ways to do it without having "this" refer to the lambda itself.
I've also shown that it's possible to refer to inner/outer classes, as
well as nested lambdas, whilst using 'this' to refer to the lambda:
I don't recall seing a suggestion of how to implement a recursive
lambda (which is 'rare' but not 'extinct') without breaking the
illegal forward reference issue that I mentioned previously. I could
have missed something; can you forward me the link of where that is
> The technical arguments for
> transparency of semantics for lambdas have been made in many contexts over
> the years. A good place to start is with Steele's "Lambda the Ultimate..."
> series of papers.
And yet, they've not been made/summarised here; nor is everyone
convinced of the 'transparency' argument. Which is not to say it's not
important to some; but let's not forget that if the issue boils down
to 'we should be able to surround body X of code with a lambda without
having to do anything else' then there are tools in compilers that let
you achieve such refactorings (and adding 'this.' where necessary).
Note that several cases exist where surrounding (or removing) bodies
of code can introduce side effects; for example, in-lining a method
can introduce the same named variable in a block of code; IDEs detect
this and warn/prevent its use.
More information about the lambda-dev