return when desugaring to closures

Lex Spoon spoon at
Thu Oct 9 15:05:55 PDT 2008

On Thu, Oct 9, 2008 at 5:31 PM, Brendan Eich <brendan at> wrote:
> JS has break from labeled statement, and continue to labeled loop bottom, a
> la Java. These look trouble-free to me. Let me know if you see a hard case.
> Thanks,

My question was whether the semantics of break and continue would support
the following:

while(true) {
  (function() {
    if (--x == 0) break;

I honestly don't know, but it shouldn't cause any real trouble to allow it.
 The implementation would be analogous to that for labeled return.  For
example, if the appropriate while loop is no longer on the stack, the
"break" would turn into an exception.

As my usual disclaimer, I am not closely following the different ES trends
including Harmony.  I'm only commenting about what could possibly make the
language more consistent and orthogonal.

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Es-discuss mailing list