Project Lambda: Java Language Specification draft 0.1.5
Joshua Bloch
jjb at google.com
Thu Feb 18 17:24:06 PST 2010
Alex,
On Thu, Feb 18, 2010 at 5:10 PM, Alex Buckley <Alex.Buckley at sun.com> wrote:
> Neal,
>
> Thanks for your comments. I agree with most and have either resolved
> them, or clarified why they don't apply, in the draft spec. Some points
> remain:
>
> Neal Gafter wrote:
> > - It is unclear what the type of "this" is in an expression lambda. Is
> > it forbidden?
> >
> > - I wonder if the identity of a lambda can change spuriously. For
> > example, if "this" refers to the lambda expression, can it be expected
> > to have the same value on each invocation of the same lambda
> > expression? In other words,
> >
> > #Object() self = #()this;
> > assert self.() == self.(); // guaranteed??
> >
> > - Similar question if the lambda has been converted to a SAM
> >
> > Object() self1 = #()this;
> > Callable<Object> self2 = self1;
> > assert self1.() == self2.call(); // guaranteed??
>
> If 'this' is banned in an expression lambda, and in returns of a
> statement lambda, then a lambda instance's identity cannot be exposed,
> and the question is moot.
>
I don't believe this (no pun intended). The ban on "this" in returns from a
statement lambda was to prevent circularities in the type inference, and
it's easy to propagate the object reference:
#Object() whoAmI = #{Object me = this; return me;}
But I would hope that the answer to Neal's question is yes: the identity of
a lambda cannot change.
Josh
>
>
More information about the lambda-dev
mailing list