Project Lambda: Java Language Specification draft
Mark Thornton
mthornton at optrak.co.uk
Sun Jan 24 10:45:03 PST 2010
Peter Levart wrote:
>
>> #()( {1,2,3} ) // Proposed collection literal expression from Coin
>>
>
> Well, without parentheses the above example shows why the proposed collection literal expression
> syntax is inappropriate. That syntax is reserved for statements - expressions should not mess
> with it. Without mandatory parentheses, this is ambiguous:
>
> #() {}
>
> ...is this an expression lambda returning empty collection or a statement lambda returning void?
>
Unfortunately Java already has array initialisation using {}, so the
syntax clearly isn't reserved just for statements. I think that existing
use for array initialisation was one of the reasons for using {} in
collection literals instead of [].
Mark Thornton
More information about the lambda-dev
mailing list