Syntax... (errata)

tronicek at fit.cvut.cz tronicek at fit.cvut.cz
Sun Nov 22 01:25:27 PST 2009


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