Description
Especially with generics ( #869 ) it might get more important to allow the definition of functions inline. There has also been a proposal to have require()
take a custom error, and due to the evaluation rules, it might be an option to take a function that returns an error as the second parameter.
Both use-cases demand a shorthand notation to define inline functions like we have in python or rust.
Proposal:
The expression (Param...) => Expression
evaluations to an internal function type that returns the value of the expression. The return type of the function is the type of the expression.
This can be shortened to => Expression
if the parameters are empty.
If we want to allow full code blocks like in (Param...) => { ... }
, we need explicit return statements and probably also return variables to be specified explicitly.
Capturing of local variables is a whole other problem.