3 ms·
I wouldn't say gotos are fine, but they're sometimes better than alternatives. I'll take a "goto" to an error-cleanup cascade at the end of a function over ten
by notacoward 8y ago
I wouldn't say gotos are fine, but they're sometimes better than alternatives. I'll take a "goto" to an error-cleanup cascade at the end of a function over ten nested three-line functions, a mini state machine, or lots of little state variables (the most common alternatives) any day. If the language has destructors or deferreds or anything else that automatically triggers when leaving scope that's probably even better, but some older languages - notably C - don't, so dogma often leads to worse alternatives.