Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcrware!jejones From: jejones@mcrware.UUCP (James Jones) Newsgroups: misc.misc,comp.misc Subject: Re: The "evil" GOTO (Was: 25 Years of BASIC) Summary: a plea for understanding in a mechanized ethos Keywords: flogging, horses, dead Message-ID: <1166@mcrware.UUCP> Date: 7 May 89 11:48:40 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> <1814@ubu.warwick.UUCP> <11136@bloom-beacon.MIT.EDU> <24047@agate.BERKELEY.EDU> <1384@cygnet.CYGNETSYSTEMS> Reply-To: jejones@mcrware.UUCP (James Jones) Organization: Microware Systems Corp., Des Moines, Iowa Lines: 33 Xref: utzoo misc.misc:5990 comp.misc:5991 In article <1384@cygnet.CYGNETSYSTEMS> mark@cygnet.UUCP (Mark Quattrocchi) writes: >This is great! Now we have two incorrect versions. Open eyes, read original, >duplicate. I suppose they did this because the program would be twice as long >if they made it compatible with the original. /* Sorry, I couldn't resist changing the prompt... :-) */ printf("I want your sex: "); while (gets(answer), (answer[0] != 'm' && answer[0] != 'f')) printf(" or only: "); Admittedly (1) this version, like most of those I've seen so far, evades the question of gets() failure (though unlike the original version, it does *not* test the input before it's been read!), and it does presume that stdout is unbuffered so that the user sees the prompt (like the original) (2) if the preparation for the checking were very much more complicated, one would have to drop back to using a break statement (where's Algol 68 when you really need it?) (3) the *true* dammit-structured-programming-is-a-hoax-and-only-good-enough- for-quiche-eaters-who-can't-really-program type would still object to this code because this loop may be followed by a redundant test of answer[0]! and indeed, the objection in (3) could be a reasonable one, if the test for validity were particularly complicated. Let's all go read or reread Knuth, "Structured programming with goto statements" (*Computing Surveys*, December 1974), so we can stop flogging this dead horse, OK? It hasn't *quite* been 25 years since Dijkstra's famous letter, but it's close. James Jones