by poutine · 17y ago · 0 comments
I notice that the code contains the use of 'goto' to handle an error condition. Seems clean.
Being somewhat of a intermediate programmer I've always read to stay away from 'goto'. Anyone care to comment on the use of it in Objective-C?
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-ex..., objective-c has exceptions, but they're resource intensive and should be avoided.