Syntax... (errata)

Reinier Zwitserloot reinier at zwitserloot.com
Sun Nov 22 02:17:49 PST 2009


fun? + a few million to the idea of using 'fn' or # instead.

Zdenek, I'm guessing that you find:

fun X => {codeblock}

readable primarily because you have experience with plenty of other
languages. Java users that don't take an interest to closures-dev usually
don't have that experience, so any statements about whether something looks
'natural' or 'feels java-like' by any of us is probably not worth all that
much. We've been tainted by too much knowledge :)

 --Reinier Zwitserloot

On Sun, Nov 22, 2009 at 10:25 AM, <tronicek at fit.cvut.cz> wrote:

> Hi,
>
> this is very readable for me. In grammar, commas between params are
> missing and there is ambiguity:
>
> fun X => { throw new NullPointerException(); }
>
> because X can be a name of closure or a return type. But probably this is
> not crucial, because anonymous lambda and named functions will not appear
> on the same place.
>
> Z.
> --
> Zdenek Tronicek
> FIT CTU in Prague
>
>
> Vladimir Kirichenko napsal(a):
>
> > a) Anonymous lambda:
> >
> > EBNF:
> >
> >       /AnonymousLambda/:
> >               fun /TypeSpec/ => /Body/
> >       /TypeSpec/:
> >               /Type/? /ParamsSpec/? /ThrowsSpec/?
> >       /ParamsSpec/:
> >               ( /Param/+ )
> >       /Param/:
> >               /Type/ ID
> >       /ThrowsSpec/:
> >               throws /ExceptionType/+
> >       /Body/:
> >               /Expression/ | { /StatementList/ }
> >
> ...
> > b) Named function declaration:
> >
> > It's very similar to the anonymous lambda except it has identifier, uses
> > assignment operator instead of implication ( => ), and has no param
> > identifiers:
> >
> > EBNF:
> >
> >       /Function/:
> >               fun /TypeSpec/ /Assignment/?
> >       /Assignment/:
> >               = /AnonymousLambda/
> >       /TypeSpec/:
> >               /Type/? ID /ParamsSpec/? /ThrowsSpec/?
> >       /ParamsSpec/:
> >               ( /Type/+ )
> >       /ThrowsSpec/:
> >               throws /ExceptionType/+
> >
> ...
> > c) Named function declaration aka short form. Difference between c) and
> > b) are IDs in param spec and implication (=>) instead of assignment. So
> > basically it's Anonymous lambda with name:
> >
> > EBNF:
> >
> >       /Function/:
> >               fun /TypeSpec/ => /Body/
> >       /TypeSpec/:
> >               /Type/? ID /ParamsSpec/? /ThrowsSpec/?
> >       /ParamsSpec/:
> >               ( /Param/+ )
> >       /Param/:
> >               /Type/ ID
> >       /ThrowsSpec/:
> >               throws /ExceptionType/+
> >       /Body/:
> >                /Expression/ | { /StatementList/ }
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20091122/fa4724f9/attachment-0001.html 


More information about the closures-dev mailing list