4 ms·
> Perhaps JS will need goto I was under the impression that labeled break/continue were the equivalent.
by grayrest 14y ago
> Perhaps JS will need goto
I was under the impression that labeled break/continue were the equivalent.
- pcwalton 14y agoYou can use labeled break and continue for a lot. That said, there is some irreducible control flow that the Relooper falls down on. It's quite rare in practice, though—with if, while, break, continue, labeled break, and labeled continue, the Relooper can reloop nearly all control structures seen in actual code. But, as I mentioned, I'm willing to believe you can come up with a benchmark where you'll need goto.
- DannyBee 14y agoYes, they are equivalent (AFAICT). You can generate irreducible control flow that will still require breaks to exit loops. However, it is possible to eliminate (even in the irreducible case) all gotos, switches, breaks, and continues from a structured program. goto's can always be transformed into conditional statements or loops. break/continue can be eliminated by an extension of the control flow elimination, and use of variables + conditional flow. A real world implementation can be found here: http://gcc.gnu.org/ml/gcc-patches/2002-05/msg00109.html http://gcc.gnu.org/ml/gcc-patches/2002-05/msg00109.html (it was never merged, we decided we were fine with goto/switch/break/continue)