Label statement moveable
Claude Pache
claude.pache at gmail.com
Tue May 26 21:02:32 UTC 2015
> Le 26 mai 2015 à 21:48, Brendan Eich <brendan at mozilla.org> a écrit :
>
> I'm not sure what you mean by limited goto, but your example works since ES3 in JS. Underused part of the design: break from labeled block or if, no need for do-while(0) nonsense.
>
> /be
I guess that his example misreferred to my case earlier in that thread:
```
foo: do {
// ...
if (bar)
continue foo
// ...
break
} while (true)
```
(It’s too easy to miss that `continue` applied to `while(false)` doesn't do what is meant.)
Anyway, for rare cases not covered by `break label`, as you noted, proper tail call is a satisfactory way to spell `goto`:
```
;(function foo() {
// ...
if (bar)
return foo()
// ...
})()
```
—Claude
>
> Michał Wadas wrote:
>> I'm not sure if limited "goto" should be really considered harmful.
>> Dijkstra has written his essay on unlimited goto, that could jump from
>> any point in code to any other point in code.
>> I don't see reason why limited "goto" that is semantically equivalent
>> (or little more powerful) to
>> x: do {
>> continue x;
>> } while(false);
>>
>> should be considered harmful (anyway - it's useful almost only for
>> implementing state machines).
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
More information about the es-discuss
mailing list