Brendan Eich wrote:
> On Oct 9, 2008, at 3:05 PM, Lex Spoon wrote:
> 
>> On Thu, Oct 9, 2008 at 5:31 PM, Brendan Eich <[EMAIL PROTECTED]>  
>> 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;
>>   })();
>> }
> 
> That's currently a specified error (possibly at runtime; chapter 16 of  
> ES3 allows it to be at compile time).
> 
> So a future edition could allow it, probably without opt-in  
> versioning. Our compatibility model does not guarantee exceptions,  
> since it allows contemporaneous extensions that remove those  
> exceptions (see ES3 chapter 16 again, second bulleted list, first  
> bullet -- these lists need their own sub-sections and numbers!).

So what should f(5, 0) do?

function f(x, h) {
  while (true) {
    try {
      if (h == 0)
        h = function() {break};
      if (x != 0)
        f(x-1, h);
      else
        h();
    } catch (e) {
      alert("caught " + e + " on " + x);
    } finally {
      alert("f called finally on " + x);
    }
    alert("f looping on " + x);
  }
  alert("f exited on " + x);
}

    Waldemar
_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to