3 ms·
The use of "goto" is fine and more legible in some contexts, such as jumping to the "cleanup" part of a function. You can avoid it, but it'll involve one of re
by avar 5y ago
The use of "goto" is fine and more legible in some contexts, such as jumping to the "cleanup" part of a function.
You can avoid it, but it'll involve one of repetition, a wrapper function, or "formalizing" the cleanup so that it's your only cleanup call. Depending on the situation those are all going to be way more verbose.
Some advanced use cases include jumping between "case" labels, or jumping into the middle of a loop. Most of the time that's bad practice, but in the cases that benefit from them it's much better than the alternatives.