Documentation of Project Coin features as implemented in the JDK 7 developer preview

Rémi Forax forax at univ-mlv.fr
Wed Mar 9 07:08:33 PST 2011


On 03/09/2011 04:00 PM, Maurizio Cimadamore wrote:
> On 09/03/11 14:30, Rémi Forax wrote:
>> On 03/09/2011 03:17 PM, Maurizio Cimadamore wrote:
>>> On 09/03/11 13:49, Eamonn McManus wrote:
>>>>> So it is more a compiler bug erroneously accepting spaces 'inside' 
>>>>> the
>>>>> diamond. The compiler should be fixed.
>>>> I don't understand this. We're not introducing a new lexical<>   
>>>> token,
>>>> are we? So obviously the compiler must allow spaces between<   and>,
>>>> as between any pair of tokens. Stylistically, some people might prefer
>>>> to write List<   Integer>, say, and would certainly be surprised not
>>>> to be able to write List< >.
>>> I think it would be better if the compiler would be stricter about 
>>> this,
>>> and to deal with diamond as if it were a token - otherwise, programmer
>>> might abuse of current behavior:
>>>
>>> new ArrayList< >();
>>>
>>> new ArrayList<
>>> >();
>>>
>>> Which is ugly.
>>>
>>> Maurizio
>> It's not fundamentally different from
>> new ArrayList
>> <>
>> ();
>> which is legal.
> I see, so since the above is allowed, let's add a further level:
>
> new ArrayList
> <
>>
> ();
>
> :-)
>> And considering<>  is a kind of new operator is weird.
>>
> I haven't used the 'operator' word once in my earlier emails.

Yes, but we both know how the scanner of javac will name it :)

>> As Éamonn says new ArrayList<  String>  is legal so new ArrayList< >
>> should be legal.
> As I said, I think that this argument can go both ways: one can think 
> that diamond is special enough to deserve special treatement; on the 
> other hand, one would like diamond to be uniform with standard type 
> argument lists. In my opinion, the benefits of treating '<>' as a 
> single token outweights the problems (at the end of the day, the only 
> arguably sensible thing that you couldn't do is 'Foo< >' - note the 
> space).
>
> Said that, all this is speculation - as Ulf pointed out, the spec is 
> explicitly allowing whitespaces inside diamonds (strange thing is that 
> doesn't seem to allow other separators... but I think that needs to 
> follow if '<' and '>' are separate tokens).
>
> Maurizio
>> Rémi

Rémi




More information about the coin-dev mailing list