Sometimes code with `goto` is simply easier to understand. You have to be careful, but dismissing it completely is throwing out a tool.
Sometimes code with `goto` is simply easier to understand. You have to be careful, but dismissing it completely is throwing out a tool.
The idea comes from Dijkstra and he sure as hell did consider it a blanket rule: "I became convinced that the go to statement should be abolished from all 'higher level' programming languages (i.e. everything except, perhaps, machine code)."
When I was early on in code I abused the GOTO, once I learned it was taboo, I was forced to learn how to structure functions/statements in a way that flowed smoothly and created readability in the code that wasn't there before. Now that I understand the pitfalls, I use goto primarily in the "Bailing Out" form described int he link. To try and force the code to do what it does without the goto would likely create a bigger mess as I'd just be nesting statements beyond ever growing if-else branches designed to kick out when failure conditions occurred.
It tends to frustrate excellent developers though, so it's a tricky weapon to wield.
Of course, it also tends to frustrate those who only think they're excellent.