Oh nooo! (gotos)

John Stanley john at ontek.UUCP
Sat Sep 9 11:09:55 AEST 1989


In article <12793 at pur-ee.UUCP>, lewie at pur-ee.UUCP (Jeff Lewis) writes:
> This, I would say, is just as structured as the simple 'break' and 'continue'
> that I presume most people have no problem with.  Of course C doesn't offer
> this obvious functionality, so you fake it with the occasional 'goto'.  Is
> there anything wrong with this?

Absolutely not.  The main objection to the use of 'goto' is when it is a
substitute for careful design.  It is perfectly possible to use the 'goto'
statement in a structured manner, as you point out.  To reject a useful
language construct purely on the basis of some sort of "purity of code"
fetish is quite foolish.  The point here is to make careful use of what can
be a most unclear construct.  I am sure we have all seen code which does
not have 'goto's which is quite horrible, so merely eschewing this one
feature does not guarantee high quality code.  Conversely, the presence of
a 'goto' in a piece of code does not automatically render it unclean. :-)

The argument against 'goto' was originally (I believe) an argument against
the *indiscriminate* use of it in lieu of other control structures, not
against the 'goto' statement itself.

	  JAS



More information about the Comp.lang.c mailing list