Lambda Conversion Considered Harmful?

Neal Gafter neal at gafter.com
Fri Feb 19 15:58:14 PST 2010


On Fri, Feb 19, 2010 at 3:56 PM, Neal Gafter <neal at gafter.com> wrote:

> On Fri, Feb 19, 2010 at 3:36 PM, Joshua Bloch <jjb at google.com> wrote:
>
>> Just to echo Alex's concerns, I was fooled by this, hence my statement
>> that
>> it was converting from one interface to another. JLS 3 (Section
>> 5.1.5)<
>> http://java.sun.com/docs/books/jls/third_edition/html/conversions.html
>> >says
>> "
>> A *widening reference* conversion exists from any type *S* to any type
>> *T*,
>> provided *S* is a subtype
>> (§4.10)<
>> http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#120403
>> >
>>  of *T*."  The lambda conversion described in CfJ does not meet this
>> specification, so it's wrong to call it a widening reference conversion.
>>
>
> This is clearly a bug in the JLS, otherwise the widening conversion from
> byte to int would be a widening reference conversion.
>
> CfJ's lambda conversion is defined as a widening conversion, but it isn't a
> reference conversion.
>

Just to clarify: yes, this implies that CfJ's lambda expression is a subtype
of the SAM to which it is converted.


More information about the lambda-dev mailing list