3 ms·
It's good for a simplified version of exception handling for C (granted C does have setjmp/longjmp but that's more like the complicated version of exception han
by InfiniteRand 5y ago
It's good for a simplified version of exception handling for C (granted C does have setjmp/longjmp but that's more like the complicated version of exception handling)
If you hit an error condition in deeply nested logic and need to go to common error handling code or go to a recovery point, then goto makes sense.
Often times in these scenarios simplifying the logic is also an option, but that isn't always the case, especially when dealing with external interfaces that have a lot of potential error conditions that cannot be dealt with easily from the immediate caller (I'm thinking primarily of system interfaces, but also potentially library interfaces).
From what I've seen this is the only really good scenario for goto and I think the examples in the article more or less fall into this category of escaping from deeply nested error cases.
- brundolf 5y agoMakes me realize that the way some people use caught-exceptions is actually just reaching for goto in a language that doesn't have it