Xref: utzoo misc.misc:5918 comp.misc:5935 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-lcc!lll-winken!uunet!mcvax!ukc!warwick!mirk From: mirk@warwick.UUCP (Mike Taylor) Newsgroups: misc.misc,comp.misc Subject: The "evil" GOTO (Was: 25 Years of BASIC) Summary: It ain't *that* bad Keywords: Guinness, phlegm, mackerel, intestines Message-ID: <1814@ubu.warwick.UUCP> Date: 4 May 89 13:12:14 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> Sender: news@warwick.UUCP Reply-To: mirk@uk.ac.warwick.cs (Mike Taylor) Organization: Computer Science, Warwick University, UK Lines: 56 In article <3, I think> gould@rosemary.cs.reading.ac.uk (Adrian Gould) writes: > Lets eradicate the GOTO from all languages. I hate it when people say things like that; As if you can just wave a magic wand over a language by excising GOTO, and everything will be alright. Listen, just 'cause Quiche-eater Wirth connected GOTOs with lack of structure geenrally, doesn't mean either that (A) ALL use of GOTO is unstructured and obfuscatory, or that (B) ALL obfuscated code is due to use of GOTO -- so why is it that so many people seem to believe these myths? 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: "); } Why make the test twice? Huh? Huh? Answer me that, all you obsessed anti-GOTO campaigners. The *natural* way to express the above is: printf ("Enter your sex: "); LABEL: gets (sex); if (sex != "m" && sex != "f") { printf (" or only: "); GOTO LABEL; } Better examples abound, but in time honoured way, elude me now that I need them. How many times have you seen people using "for (;;;) ... break;" when you *know* that by "break" they mean "GOTO"? In many situations GOTO is natural - the response of a thinking being to it is to traid to know when those times are. Clearly irresponsible use of GOTO is bad; clearly spaghetti-junction programs written in languages with no other flow-control are bad (Frog knows how APL people manage!) But let's get this in perspective. It isn't GOTO's fault. It's yours for using it badly. It makes me laugh when people push Ada as a good real-time langauge because iof its "powerful exception-handling". "Exception-handling". Do you know what that means? Yup, you guessed it, it's a fancy word for GOTO. Luverly, Eh? Dress it up to look nice'n'respectable, install it as a fabulous feature in a DoD-sponsored langauge-to-end- all-languages, and everyone loves it. Well they ain't fooling me. I know goto when I see it. The reason Ada seems more powerful for having GOTO is simply because the programming paradigm that is pushed together with Ada causes the programmer to use GOTO in a disciplined way. THAT is the answer to the GOTO problem. Teach people to recognise WHEN to use it, and teach them to know HOW to use it. ______________________________________________________________________________ Mike Taylor - {Christ,M{athemat,us}ic}ian ... Email to: mirk@uk.ac.warwick.cs Unkle Mirk sez: "G G7/B C F G G7/B B7 Em; Dm7 G7/B C Gdim7 G D C Gdim7 G D Cm"