Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Commenters: Do not continue the bickering back and forth in comments. If you have a better answer or you want to improve your answer, please do so on the question this one duplicates. If you want to have a constructive conversation about the topic of this post, please do it in chat. Commented Dec 19, 2011 at 9:33
  • Amusingly, use of other branch/loop constructs leads to one of the more prominent uses of goto: Jumping out of nested conditionals/loops, when there's a viable reason to do so and breaking out without goto would look clunky and/or require multiple potentially-costly checks. (I believe the most commonly discussed case of this is error handling, with "specific end condition met in nested loop mid-iteration" being the next most common.) Commented Jul 14, 2019 at 19:35
  • @Justin: In C++, I have yet to see such a piece of code that could be made easier to understand by applying a goto, but would not become even easier to understand by introducing additional (inlined) functions. Commented Sep 4, 2019 at 19:10
  • That's a good point, too, I was mainly looking at cases where it's less elegant to e.g., break things apart into discrete functions. Not all that common now, though, to be sure, especially with how much languages have progressed. Commented Sep 5, 2019 at 0:10