Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!wugate!uunet!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: The final word on GOTO (Don't I wis Message-ID: <972@crdos1.crd.ge.COM> Date: 10 Oct 89 16:52:36 GMT References: <6396@ficc.uu.net> <725@thor.wright.EDU> <6430@ficc.uu.net> <154@nmtvax.nmt.edu> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Distribution: na Organization: GE Corp R&D Center Lines: 44 In article <154@nmtvax.nmt.edu>, dwho@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@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