Short Functions

Brendan Eich brendan at mozilla.com
Sat May 21 17:56:28 PDT 2011


On May 21, 2011, at 5:28 PM, Isaac Schlueter wrote:

>    function (a, b, c) { return a + b * c }
> 
> but I really don't want to replace our existing simple semantics.

Nothing is replaced.

You mean adding new semantics for new syntax is like replacing current semantics with current + new, which is too much?


> I see a lot of the discussions of short function syntax seeming to
> imply ruby-block semantics, with the "return returns from the parent"
> idea.  It would be great to separate those two concerns.  They are
> very different.  One is sugar, the other is a much more radical change
> to the way the language works, which I'm not altogether convinced is a
> good or useful thing.

It's essential to the control abstraction programmability. Take a look at the examples. You want those block-looking things to support Tennent's Correspondence Principle. Return from a block in JS today returns from the enclosing function. Same for return from a block-lambda in a function. It's an early error to return from global code, and will be in a block-lambda in global code.

Why is this so bad? JS programmers return, break, and continue from blocks all the time.

/be


More information about the es-discuss mailing list