optional "function" keyword

Brendan Eich brendan at mozilla.org
Tue Mar 6 13:42:13 PST 2012


Isaac Schlueter wrote:
> I'd suggest dropping the
>
>     Identifier_opt ( FormalParameterList_opt ) [no LineTerminator here]
> IniitialValue
>
> production.  Wouldn't that mean that you could have something like this?
>
>      var allA = list.map(() "a")
>
> I think the curly braces are ok here.  Hated keywords should be
> attacked one at a time, imo.

Divide-and-conquer in language design can go down many bad paths. One is 
that if we attack 'return' naively, we make a completion-value leak 
hazard (discussed many times on this list).

Block-lambda revival uses a different-looking syntactic special form to 
call out the places where TCP holds and return means the same in the 
body as in the enclosing function.

For what we're discussing here, no such TCP should be contemplated 
(you'll be relieved to hear :-P). That means we can't just say "curly 
braces and impute the return value from the completion value", though -- 
not without facing the dilemma of unintended completion value leaks. 
There's no a-priori solution to this dilemma.

Thus my interest in a low-precedence expression-bodied alternative 
syntax for short functions.

/be



More information about the es-discuss mailing list