The final word on GOTO (Don't I wis

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Wed Oct 11 02:52:36 AEST 1989


In article <154 at nmtvax.nmt.edu>, dwho at nmtvax.nmt.edu (David Olix) writes:

	[ how to avoid goto with a flag ]

|  case_matched = 1;
|  switch (format_char)
|  {
|    case 'd':  the stuff I put under d; break;
|    case 'o':  the stuff I put under o; break;
|    case 'x':  the stuff I put under x; break;
|    case 'u':  the stuff I put under u; break;
|    default:  case_matched = 0;
|  }
|  if (case_matched)
|    the stuff I put under donum;

|  I'm not really arguing whether or not to use goto's here; I'm arguing that
|  adding one flag (case_matched) does not a 'whole lot of flags' make.

  I believe the original problem had a default case also, therefore not
allowing the detection of no case matched. The flag would have to be
cleared in each case. I *think* that's what I posted as an example of
how to do it without a goto, but my disk monitor had to do 1 massive
expire over the weekend and I don't have that stuff online.

  There is no question that anything can be done without a goto,
although I still feel that some of the things done in the quest of
avoiding gotos result in equally obscure code. When I first became
convinced that structured was the way to go (and about all we had in
those days was Algol-60), I did stuff like that. I'm more likely to
rethink and avoid both the flags and the goto these days, but I no
longer feel that a goto is a religious issue.

  Just a note: use of goto in net software.
	B news P/L 17, 91 gotos in 22k lines, one macro expands to goto
	rn 124 in 22k lines
	C news 3 in 28k lines

  I conclude that other people find goto useful once in a while, too.
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.lang.c mailing list