dosadiexperiment

dosadiexperiment t1_iyc7bxz wrote

It's what you tell beginners to keep them from making too much of an unmaintainable spaghetti mess, which is what people will generally end up with if they think of it as a general-use tool in their toolbox, instead of merely for a few specific narrow situations. But it's not quite as absolute as it's usually presented.

The Linux kernel uses gotos in a structured way that's helpful. (If you're using C++, you should probably instead use RAII to do what they're doing, but in C careful use of goto can be worthwhile to get a similar effect.)

Some would claim breaking out of multiple levels of nested loops also is a good use case, and produces code that's easier to read than trying to chain breaks through multiple loops. Common wisdom is you're better off putting your loops in a function and using 'return' when you need this, but it's a debatable point when goto is in the language.

5