3 ms·
In this case, he's emulating the effect of an exception in a language which doesn't support them particularly well[1]: logging the exception message and then mo
by Empact 17y ago
In this case, he's emulating the effect of an exception in a language which doesn't support them particularly well[1]: logging the exception message and then moving to a "rescue" or "catch" block which does necessary cleanup.
This is one of the few uses of goto which I find acceptable, and it's only necessary because these languages lack exceptions. Using goto for normal control flow, or even complex error handling, can be quite the nightmare. Particularly bi-directional gotos.
Given the situation though, that it seems he's avoiding exceptions out of habit or performance concern, I'd still use an exception in this case, rather than the goto, to protect myself from probable misuse and unpredictability.
[1] according to this http://stackoverflow.com/questions/324284/how-to-throw-an-exception-in-objective-c-cocoa http://stackoverflow.com/questions/324284/how-to-throw-an-ex..., objective-c has exceptions, but they're resource intensive and should be avoided.