3 ms·
Gotos can be used to effectively accomplish try/catch in C. As long as you stick to a safe goto idiom like this then they can be useful. In general, an inexperi
by umvi 5y ago
Gotos can be used to effectively accomplish try/catch in C. As long as you stick to a safe goto idiom like this then they can be useful. In general, an inexperienced programmer taught that goto is okay is probably not going to stick to safe idioms and will instead create spaghetti code, hence why they are steered away.
- SAI_Peregrinus 5y agoI'd be more likely to use setjmp/longjmp to accomplish try/catch in C than goto. Goto is fine for error handling, but exceptions are a bit different, since they have the try/catch/finally structure. Personally I prefer to avoid exceptions, but if I were forced to implement them I'd not use goto!