2 ms·
As do Java, Common Lisp, Ada, Javascript, and probably a lot of others. Breaking from inner loops is a common thing and having to use special condition variable
by Jtsummers 5y ago
As do Java, Common Lisp, Ada, Javascript, and probably a lot of others. Breaking from inner loops is a common thing and having to use special condition variables is error prone, in comparison, and potentially more time intensive. Labeled loops let you keep the premise of goto-less programming in structured programming while permitting a weakened jump-to-label (the program can't jump from anywhere to that label, only in the context of the loop). Since they aren't (usually) able to be used from other arbitrary points you still get the cleaner control flow that structured programming promotes.
- ratrocket 5y agoI was writing a (less informed!) sibling comment at the same time. Great observation that I hadn't considered: what I called a "labeled break" or "continue" is safer than bare goto since you can't jump from anywhere to anywhere. Thanks for making that plain!