Syntax decision

Stephen Colebourne scolebourne at joda.org
Wed Sep 28 08:28:02 PDT 2011


On 28 September 2011 15:41, Brian Goetz <brian.goetz at oracle.com> wrote:
> The nilary syntax is still a thorn.  But the obvious solution outlined
> below -- allow elision of the () -- leads to a syntactic ambiguity.  If
> -> { statement; } were a valid lambda, then is:
>
>   (identifier) -> { statement; }
>
> a one-arg lambda with inferred type, or a cast of a nilary lambda?
>
> If people have brilliant other suggestions for nilary lambda syntax,
> we'd consider it.

You'll have to allow these anyway for consistency:
  () -> expr
  () -> {stmt;}

You could use an "extended arrow" for nilary:
  --> expr
  --> {stmt;}

where the extra dash effectively means "nothing"

  shortCutAnd(() -> size >= 0, () -> size < max);
  shortCutAnd(--> size >= 0, --> size < max);

Stephen


More information about the lambda-dev mailing list