Re: break, continue, goto
Re: break, continue, goto
- Subject: Re: break, continue, goto
- From: Karl Kraft <email@hidden>
- Date: Mon, 4 Aug 2003 06:36:33 -0500
On Monday, Aug 4, 2003, at 05:04 US/Central, Stephan Lichtenauer wrote:
David,
....you never need a goto. If you need one, you are doing something
wrong and you should rethink and reorder your code....
A different matter is break and continue, you definitely need them in
a switch and I think there are a lot of algorithms where at least a
break also makes sense when programming a loop.
I concur with this. The only place when I have seen goto not used,
where it should have been is in exception handling code where a
function must clean up after itself when something goes wrong. In
fact, NSException (last I looked) uses longjmp which is basically a
non-local goto.
The code in question was RSAREF, which used many many nested loops to
achieve the same effect as recommeded above. One or two nested loops
is fine, but some parts seemed to be a dozen while loops deep using a
variable at each to detect the exception and leave the loop. I guess
the moral is that every language feature has some valid use, and it's
good to know that they exist, even if 99% of programs never use them.
--
To purchase it is not like spending money
but rather it is an investment in the future
in a blow against the empire
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.