return when desugaring to closures

Brendan Eich brendan at mozilla.org
Sat Aug 23 19:15:20 PDT 2008


On Aug 22, 2008, at 4:02 PM, Lex Spoon wrote:

> You raised return, break, continue, and arguments before, and I
> addressed those.

Where? Your syntax-free suggestion of labels (as in break to label  
and continue to label) does not address the problems with |this| or  
arguments.


> So is there anything that is really an issue with the proposed  
> desugaring?

Of course. First, it's unnecessary and confusing to have two ways to  
write

(function (x, y) {...})(a, b)

one of which has a clear target for return in ..., the other not. I'm  
still waiting to see a proposal for unambiguous return-value-to-label  
syntax. The dynamic binding of |this| means in ... it will be the  
global object, even if it is not in the outer context. And arguments 
[0] aliases x. Break compatibility? Then you break  
"desugaring" (which is a sacred cow anyway).

>> If you look from 100,000 feet, you could say they're all similar,  
>> but they
>> are not the same. Just one example: Smalltalk has block objects,  
>> quoted code
>> you can activate by sending a message. You could say that's just  
>> like a
>> function, except where it is quite different
>> (http://c2.com/cgi/wiki?SmalltalkBlockReturn).
>
> Brendan, that is exactly the non-local return I was talking about.
> The success of this construct in multiple languages proves that it is
> at least workable.  Its repeated selection proves that others have
> found it desirable.  Now, there might be something special about
> JavaScript that would cause it not to work well.  What difference
> would that be, though?

I still don't know exactly what you mean. Instead of hand-waving,  
please write explicit syntax. How would non-local return work? How  
would it desugar? How would you deal with |this| and arguments?

You can stop addressing me by name, I'm the only To: addressee.

/be



More information about the Es-discuss mailing list