optional "function" keyword

Jorge jorge at jorgechamorro.com
Sat Mar 10 04:22:30 PST 2012

On Mar 9, 2012, at 9:45 PM, Brendan Eich wrote:
> I originally wrote up
> http://wiki.ecmascript.org/doku.php?id=strawman:arrow_function_syntax
> and
> http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival
> as mutually exclusive alternatives, but changed the framing for the latter to recognize the new semantics (beyond =>'s |this| TCP conformance). Yet I agree that if we get shorter function syntax together, block-lambdas lose some of their "oomph".
> For downward funargs called by the control flow, and so for novel control structures, with paren-free call affordances even, they still have some win. Perhaps not enough to make it into any future edition without prototyping in popular engines and grass roots pressure...
> Anyway, I'm still trying to get something for shorter function syntax into ES6. I think TC39 can yet make an exception if we have our validation story figured out. That is where to focus fire.

If short function syntax and block lambdas are mutually exclusive, then the block lambdas' syntax should be considered as an alternative for short function syntax, that is, {| params | /* body */ } is a perfectly valid candidate for short functions, without TCP.

And given that `this` is an invalid name for a parameter, to indicate a bound this we could simply include it in the parameters list:

{|this, arg1, arg2| /* body */} bound `this`
{|arg1, arg2| /* body */} unbound `this`

More information about the es-discuss mailing list