Skip to main content

Timeline for Is using goto ever worthwhile?

Current License: CC BY-SA 2.5

8 events
when toggle format what by license comment
Jan 6, 2021 at 21:05 comment added Gellweiler When you have control structures multiple levels deep, refactor your code. This is a major code smell. And it is easily avoidable and will make your code so much easier to read. A goto may sometimes be an OK solution to leaving a loop and I have done it many times when hacking something fast but it is a sign you're probably doing it wrong. That being said there are valid usages of goto in plain C.
May 19, 2020 at 21:58 comment added gnasher729 @JohnR.Strohm The only reason why you say "goto is never an elegant answer" is because you made your mind up that goto is never an elegant answer, and therefore any solution using goto cannot be an elegant answer.
Jan 22, 2019 at 4:17 comment added Joshua @JohnR.Strohm: Second most missed feature on switching from VB.NET to C#: the Do loop. Why? Because I can change the one loop that needs a deep break into a Do loop and type Exit Do and there's no GoTo. Nested loops happen all the time. Breaking the stacks happens some % of the time.
Feb 6, 2016 at 21:34 comment added Sujay Phadke @JohnR.Strohm Never say never. If you use terms like "never" in programming , you've clearly not dealt with corner cases, optimization, resource contraints, etc. In deeply nested loops, goto is very much indeed the most cleanest, elegant way to exit the loops. Doesn't matter how much you've refactored your code.
Dec 27, 2011 at 13:53 comment added Chinmay Kanchi And of course, there is never the odd case when deeply nested loops are called for? Being a good programmer isn't just about following the rules, but also about knowing when to break them.
Dec 18, 2011 at 15:03 comment added John R. Strohm goto is never an elegant answer. When your loops are nested several levels deep, your problem is that you failed to architect your code to avoid the multinested loops. Procedure calls are NOT the enemy. (Read the "Lambda: The Ultimate ..." papers.) Using a goto to break out of loops nested several levels deep is putting a band-aid on an open multiple fracture: it may be simple but it isn't the right answer.
Sep 3, 2010 at 0:19 comment added Chinmay Kanchi Anyone care to explain the downvote? This was a perfectly valid answer to the question...
Sep 2, 2010 at 21:58 history answered Chinmay Kanchi CC BY-SA 2.5