Free Republic
Browse · Search
News/Activism
Topics · Post Article

To: js1138; ml1954; microgood
[...there is a "goto" in C.]

Not if you want to keep your job.

I've used "goto" in C/C++ quite a few times, and I still have a job. ;-)

Actually, while it's a good rule of thumb to avoid "goto" whenever reasonably possible (and most times it *is* reasonably possible) there are always a few times when avoiding one just for the sake of obsessive-compulsion can make the code a lot uglier than it would be otherwise.

Some of the more obvious examples are error-handling (like you're 12 levels deep in control structures and it's time to bail the hell out because of a major failure), or similar special-case scenarios.

In many of those situations, all the goto-less alternatives are even uglier than the more simple and obvious "goto CLEANUP_AND_RETURN;" option.

113 posted on 11/15/2005 6:11:47 PM PST by Ichneumon
[ Post Reply | Private Reply | To 88 | View Replies ]


To: Ichneumon

Actually, while it's a good rule of thumb to avoid "goto" whenever reasonably possible

I agree wholeheartedly. Use of 'goto' should never be 'taken lightly' and should be avoided, except when it's absurd no to use it.t

117 posted on 11/15/2005 6:19:21 PM PST by ml1954 (NOT the disruptive troll seen frequently on CREVO threads)
[ Post Reply | Private Reply | To 113 | View Replies ]

Free Republic
Browse · Search
News/Activism
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson