Function Syntax

Brendan Eich brendan at mozilla.com
Wed May 11 09:19:43 PDT 2011


On May 11, 2011, at 9:12 AM, Brendan Eich wrote:

> On May 11, 2011, at 8:52 AM, Claus Reinke wrote:
>> More concise function syntax is important, as long as the deeper
>> issues get resolved, too.
> 
> What deeper issue beyond |this| binding (lexical, dynamic, soft, etc.) do you mean, precisely?

I have another not-just-syntax issue beyond |this|-binding, already raised (http://brendaneich.com/2011/01/harmony-of-my-dreams/ "tail position"):

We already approved http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_calls -- great. But you have to write "return expr" to put "expr" in tail position. Just "function f(){g()}" does not put the call to "g" in tail position.

Wherefore the controversial idea of http://wiki.ecmascript.org/doku.php?id=strawman:completion_reform and the reformed completion value as the implicit return value of new-syntax (-> or whatever we decide on) functions.

This has syntax helping better semantics. It's not just one or the other. It is on the boards. Alas, some fear (perhaps justifiably) completion value leaks, including unintended capability leaks.

There's no perfect answer. Shorter return syntax ("^" with an ASI change, or my "empty label" idea, "function f(){:g()}") is ugly, adds overhead, and can still be left off by mistake (making for the opposite problem from the capability leak one: returning undefined instead of the intended result of an expression evaluation).

I still think the completion value leak problem is manageable with docs, tools, and resort to good old "function" long-hand syntax. Opinions?

/be



More information about the es-discuss mailing list