for, while, if, and more can also be implemented using a jump. That doesn't matter. The problem with goto isn't that it's a jump instruction; the problem is the resulting lack of code structure. For code to readable, it you should composed of "blocks". Prematures exits (next, last, return, die, and goto as used in my C example) are an exception as they can actually improve readability. This is why they don't necessarily have the same problem as goto.
| [reply] [Watch: Dir/Any] [d/l] [select] |
Just one example what you can do with switch: Duff's device.
Switch cases have the fallthrough property, so those blocks can have multiple entry edges. Besides that, switch and goto have the same problem that they can enter a scope at the middle. (For instance, C prohibits bypassing the declaration of variably modified type, e.g. int foo[n]; where n is a variable too — this is more or less the same as alloca().)
The main benefit of goto is that it can be used to set up a simple FSM without using a state variable. Which is also the main problem with goto, in case the simple turns out to be "simple".
| [reply] [Watch: Dir/Any] [d/l] [select] |