Xref: utzoo misc.misc:5920 comp.misc:5937 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: misc.misc,comp.misc Subject: Re: The "evil" GOTO (Was: 25 Years of BASIC) Keywords: Guinness, phlegm, mackerel, intestines Message-ID: <11136@bloom-beacon.MIT.EDU> Date: 4 May 89 23:57:09 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> <1814@ubu.warwick.UUCP> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Organization: Massachusetts Institute of Technology Lines: 30 In article <1814@ubu.warwick.UUCP> mirk@uk.ac.warwick.cs (Mike Taylor) writes: >How many times have you seen this kind of code? > > printf ("Enter your sex: "); > while (sex != "m" && sex != "f") { > gets (sex); > if (sex != "m" && sex != "f") > printf (" or only: "); > } Indeed, this is a pretty bad example of where a goto would be useful, because you are simply illustrating what the purpose of the C do ... while construct is for: do { fprintf(stdout, "Enter your sex ( or only): "); fflush(stdout); fgets(stdin, sex, 2); fflush(stdin); } while ((*sex != 'm') && (*sex != 'f')); Granted, goto can have its uses, and exception handling is a prime example, but don't go jumping to conclusions and saying that goto is the most understandable method to use in a case where (at least in my opinion) a more "structured" construct does a better job. Jonathan Kamens USnail: MIT Project Athena 410 Memorial Drive, No. 223F jik@Athena.MIT.EDU Cambridge, MA 02139-4318 Office: 617-253-4261 Home: 617-225-8218