Syntax... (errata)

tronicek at fit.cvut.cz tronicek at fit.cvut.cz
Sun Nov 22 03:46:01 PST 2009


It is not only 'fun' vs. '#'. Compare:

#String(int, double) throws IOException | InterruptedException p;

vs.

fun String p(int, double) throws IOException, InterruptedException;

or

#String p(int, double) throws IOException, InterruptedException;


And

p.invoke(42, 3.14);

vs.

p(42, 3.14);


Z.
-- 
Zdenek Tronicek
FIT CTU in Prague


Reinier Zwitserloot napsal(a):
> 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/ }
>> >
>>
>>
>



More information about the closures-dev mailing list