Syntax decision
Stephen Colebourne
scolebourne at joda.org
Wed Sep 28 08:32:12 PDT 2011
On 28 September 2011 16:24, Henri Gerrits <henrigerrits at yahoo.com> wrote:
> Since the cast syntax can't be touched, one way out could be to change the arg delimiters for the lambda, e.g.;
>
> |x, y| -> x + y;
>
> Personally, I find this a bit more readable when the lambda is provided as an argument to a method or constructor:
>
> c.sort(|x, y| -> x > y);
>
> instead of:
>
> c.sort((x, y) -> x > y);
>
> But I'm sure you will already have considered (and rejected) '|'.
Since the decision is to go away from familiar things in Java (as
opposed to #() {stmt}), I might also favour:
|x, y| -> x + y
It is a lot clearer in many ways in complicated situations, and would
be beter for the eye in finding the target of "return" statements.
I don't know without looking closer whether this is sufficiently
distinguishable from OR however:
|| -> expr
Stephen
More information about the lambda-dev
mailing list