Short Functions

Alex Russell alex at dojotoolkit.org
Sat May 21 18:13:48 PDT 2011


On May 21, 2011, at 5:56 PM, Brendan Eich wrote:

> 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.

I think you're over-playing the use of blocks in the syntactic sense. My observation has been that when people use them, it's primarily accidental. Citing that feels like weak ground to argue from.

--
Alex Russell
slightlyoff at google.com
slightlyoff at chromium.org
alex at dojotoolkit.org BE03 E88D EABB 2116 CC49 8259 CF78 E242 59C3 9723



More information about the es-discuss mailing list