Lambda Conversion Considered Harmful?
Alex Buckley
Alex.Buckley at Sun.COM
Sun Feb 21 01:47:31 PST 2010
Joshua Bloch wrote:
> On Fri, Feb 19, 2010 at 6:15 PM, Neal Gafter <neal at gafter.com> wrote:
>
>> On Fri, Feb 19, 2010 at 4:13 PM, Joshua Bloch <jjb at google.com> wrote:
>>> I'd argue that the bug is that byte is defined to be a subtype of int.
>> This
>>> wasn't true in earlier editions of the JLS, as I recall;)
>> Earlier editions didn't define "subtype".
>>
>
> They may not have defined the term, but they did use it, for example:
>
> Assignment to an array component of reference type (§10.10, §15.13,
> §15.26.1). The type-checking rules allow the array type S[] to be treated as
> a subtype of T[] if S is a subtype of T, but this requires a run-time check
> for assignment to an array component, similar to the check performed for a cast.
>
> from page 320 of the Second Ed.
That's the only occurrence of the term, and it's basically in
non-normative text. (There is a paper waiting to be written on
specification of a specification.)
To the issue, I have noted that JLS3 5.1.5 should be restricted to
*reference* types S and T. It's just good practice to be precise.
For primitive types, JLS2 did not describe subtyping. It is irregular
for JLS3 to both carry over the enumeration of primitive conversions
from JLS2 (5.1.2/3) and also enumerate a primitive subtype hierarchy
(4.10.1). I propose keeping 4.10.1 and having 5.1.2/3 defer to it,
adding the interesting narrowing conversions of short->char,
char->short, and char->byte to 5.1.3 of course.
Alex
More information about the lambda-dev
mailing list