Usage of goto's

Alvin E. Sylvain asylvain at felix.UUCP
Wed Oct 3 05:42:50 AEST 1990


In article <1990Sep28.121230.17767 at NCoast.ORG> ramsey at NCoast.ORG (Cedric Ramsey) writes:
>
>Hello once again peoplekind. I have a question about goto's. We all
>know that there usage is taboo in any language but what better way 
>do we have to implement finite state machines. A switch statement ?
>All a switch statement is a goto statement, internally that is. So
>then, maybe it is okay to implement goto's for NFA's, DFA's, and
>transition diagrams.
>
>Is it okay for a programmer to break a TABOO intentionally; by design?

Natch, it's OK.  A coupla' points to consider, tho:
1) Just because a switch is implemented as a goto has no bearing on
   the problem.  For, While, If, etc., are all implemented with goto's
   in one aspect or another.  However, most of us don't have to *read*
   the implemented machine code.
2) Foo, I wish I'd saved the other fellow's posting where he talks
   about "Holy Law".  Very appropriate.  The point is, goto's are a
   negative impact on readability and maintainability of software,
   and, as such, should be avoided.  But only avoided to the point
   where the alternatives become a negative impact, not beyond.

There exist situations where the goto *is* the best solution, or at
least the most expedient.  I.e., don't spend a week trying to
design-out a single goto ... If you need them, *comment* them for
the next guy.  (E.g., "/* this is an error-exit goto */")

Summary: I think software development is an art, like painting or
writing, etc.  I once heard a artist (I don't remember who, but I
believe he was a playwriter) say something to the effect:
"To be great, you must have a style.  To have a style, you must
break some rules.  But you must first *know* the rules!"
--
-=--=--=--"BANDWIDTH??  WE DON'T NEED NO STINKING BANDWIDTH!!"--=--=--=-
"If you come in at 10am and leave at 7pm one day, then come in at 6am
and leave at 3pm the next day, people will deduce that you are coming in
at 10am and leaving at 3pm every day." --- me



More information about the Comp.lang.c mailing list