Implementing recursive lambda with MethodHandle

Joshua Bloch jjb at google.com
Mon Feb 22 12:32:02 PST 2010


Lawrence,

On Mon, Feb 22, 2010 at 11:46 AM, Lawrence Kesteloot <lk at teamten.com> wrote:

> On Mon, Feb 22, 2010 at 11:28 AM, Joshua Bloch <jjb at google.com> wrote:
> > Yes, but it uses an (ugly) anonymous class initialization expression.
>  The
> > whole idea of this JSR is to eliminate the need for these beasts.
>
> It concerns me that so much of the discussion on this list centers
> around the use case of the programmer writing factorial functions.
> Every recursive function I've ever written was too complex to fit into
> a lambda.


I've written plenty of shorter ones, but I do believe this (recursive
lambdas) is a corner case.


> Josh, perhaps I missed it, but I don't understand why it's so
> important to you that "this" refer to the function object. (Other than
> for a recursive call.) Can you provide a few use cases?


As I've said a few times, I believe it's the right thing to do from a
consistency standpoint. Also it's strictly more powerful than having an
unqualified "this" refer to the enclosing instance (if any): you can always
get access to the enclosing instance using a qualified this. As for use
cases, I expect that a lambda might register itself or deregister itself for
some sort of callback (e.g., change notification).

            Josh


More information about the lambda-dev mailing list