Project Lambda: Java Language Specification draft
Peter Levart
peter.levart at gmail.com
Sun Jan 24 13:43:43 PST 2010
On Sunday 24 January 2010 19:45:03 Mark Thornton wrote:
> 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.
Yes, that is an exception to the rule, but it does not cause trouble because it's applicability
context is limited. Collection literal, on the other hand, is a first class expression.
> I think that existing
> use for array initialisation was one of the reasons for using {} in
> collection literals instead of [].
I know that, but I think it is not a good decision. Mandatory parentheses in expression lambdas
clearly demonstrate that.
Regards,
Peter Levart
More information about the lambda-dev
mailing list