Lambda Conversion Considered Harmful?

Alex Buckley Alex.Buckley at Sun.COM
Fri Feb 19 15:34:17 PST 2010


Neal Gafter wrote:
> The type of a lambda expression in CfJ is not denotable in source, but 
> that isn't the same as saying that it doesn't have a type.  The type of 
> a lambda expression in CfJ is defined by the set of declared argument 
> types, result expressions, and thrown types of the lambda's body.  The 
> lambda conversion is a binary relation all of whose pairs are the type 
> of a lambda expression on the left and a SAM interface on the right.

While CfJ already avoids saying that the type of a lambda expression is 
a function type, it would be nice if the paragraph above was 
incorporated into the CfJ specification.

>      > BGGA demonstrates that you can do both with one syntax, and without
>      > the performance hit of the current draft's lambda conversion.
> 
>     It is irregular to support "conversion" from only a literal lambda
>     expression to a SAM type, rather than from any value of function typre
>     to a SAM type.
> 
> CfJ (and BGGA) doesn't define any conversions from any values of 
> function type to any other types.  Those conversions are subtype 
> relations already defined by the JLS.  In CfJ, a function type *is* a 
> SAM type; they are both handled precisely the same way by the type 
> system and the conversions, uniformly. 

OK. And just so everyone is clear: the Lambda spec does not mandate that 
a function type is a SAM type. If you were implementing BGGA today, 
would you look at using MethodHandles?

> I agree that it would be irregular for you to take this approach as
> long as you continue to define lambda expressions to be of function
> type, and make that visible in the language through a "this".

Yes.

Alex


More information about the lambda-dev mailing list