Closed privat closed 5 years ago
This extends the Nit syntax with lambdas expressions.
Lambdas are basically anonymous functions, so just accept functions without a name as expressions.
var x = fun(i: Int): Int do return i + 1 end # or on a single line var x = fun(i: Int): Int do return i + 1 end
fun, do and end are mandatory, the rest is optional
fun
do
end
var x = fun do end
The main weirdness is the mandatory end that makes the following invalid
# invalid: var x = (fun(i: Int): Int do return i + 1) # missing `end`, unexpected `)`
There is no semantic yet, nor implementation, this might come in some future PR
No way to define it without the final end?
The current grammar broke really badly if end is missing. I think that sablecc4 is required.
This extends the Nit syntax with lambdas expressions.
Lambdas are basically anonymous functions, so just accept functions without a name as expressions.
fun
,do
andend
are mandatory, the rest is optionalThe main weirdness is the mandatory
end
that makes the following invalidThere is no semantic yet, nor implementation, this might come in some future PR