Optional brackets around lambda expression
Ben Evans
benjamin.john.evans at gmail.com
Fri Jun 17 00:16:12 PDT 2011
On Fri, Jun 17, 2011 at 7:59 AM, Reinier Zwitserloot <
reinier at zwitserloot.com> wrote:
> Er, right. This redmond variant syntax of Ali Ebrahimi:
>
>
> a, b, c -> expression
>
> cannot work, as far as I can tell, in the current parser architecture of
> javac and ecj, and attempting to work around it or fix the parser is a
> massive undertaking. I think - experts, please chime in!
>
> This:
>
> process(x, y, z, a, b, c, d);
>
> is hard to differentiate from this:
>
> process(x, y, z, a, b, c, d -> 5);
>
>
It has other (human) issues as well.
Consider process(x, y, z, a, b, c, d - 5); or process(x, y, z, a, b, c, d >
5);
Both are regular calls taking a bunch of parameters, and to my eyes at
least, it scarcely leaps off the page that:
process(x, y, z, a, b, c, d -> 5);
is making use of delayed execution via a lambda expression, and:
process(x, y, z, a, b, c, d - 5);
process(x, y, z, a, b, c, d > 5);
are both "regular" method calls. It isn't even that difficult to construct
sane examples where different overloads of the same method would take
"regular" parameters or lambdas.
Thanks,
Ben
More information about the lambda-dev
mailing list