Reuse 'do' keyword instead of hash sign (#)
Brian Goetz
brian.goetz at oracle.com
Mon Jun 20 08:31:55 PDT 2011
I think "lambda expression" is the right thing to say when you are
referring to the lambda itself. It is an expression, but its type is
contingent on its context (it is target-typed) and undergoes a
conversion of sorts before it becomes a SAM.
If you want to refer to the object instance that is the result of SAM
conversion, call that the SAM instance or the SAM object -- which is an
object. (You can't assume much about its identity -- the compiler will
likely make sure that all instances of "stateless" lambdas are really
the same object, a la the "Flyweight" pattern.)
On 6/20/2011 11:11 AM, Jack Moxley wrote:
> I do know that they arn't objects, Its difficult to find the correct
> word to use. Would function pointer be more suitable?
>
> ------------------------------------------------------------------------
> *From:* Brian Goetz [mailto:brian.goetz at oracle.com]
> *To:* lambda-dev at openjdk.java.net [mailto:lambda-dev at openjdk.java.net]
> *Sent:* Mon, 20 Jun 2011 14:38:38 +0100
> *Subject:* Re: Reuse 'do' keyword instead of hash sign (#)
>
> > I think you misunderstood me, I suppose it really depends on whether
> > you conceptually consider lambda expressions to be objects and thus
> > typed, or you don't. Which I, for right or wrong do.
>
> I would say that intuition will work against you in the long run.
>
> Lambda expressions are not objects. They don't have an object identity.
> The 'this' keyword, if it means anything in the context of a lambda,
> is the *enclosing* object, not the target of the SAM conversion.
>
> Lambda expressions are *converted to* an object -- an instance of a SAM
> type. (A reasonable analogy is the type of 'null' -- null is
> assignment-compatible with multiple reference types, but is not
> intrinsically of type Object.) The object-nature of this converted
> value is not discernable from within the lambda -- and eventually will
> be optimized away by the VM.
>
> In a future possible version of Java that has reified function types,
> lambda expressions will be function-typed, and functions are not
> (necessarily) objects.
>
>
>
More information about the lambda-dev
mailing list