Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uxc!tank!shamash!nis!quad!dts From: dts@quad.uucp (David T. Sandberg) Newsgroups: comp.misc Subject: Re: The "evil" GOTO (Was: 25 Years of BASIC) Message-ID: <132@quad.uucp> Date: 10 May 89 02:31:01 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> <1814@ubu.warwick.UUCP> <698@occrsh.ATT.COM> <852@umecs.cs.umu.se> Reply-To: dts@quad.uucp (David T. Sandberg) Organization: Quadric Systems, Richfield MN Lines: 47 In article <852@umecs.cs.umu.se> christer@rachel.UUCP (Christer Ericson) writes: LOCATION: | I think all of you who have been discussing GOTO's should take a look at the | March '87 issue of CACM and read Rubin's '"GOTO Considered Harmful" Considered | Harmful' along with Dijkstra's reply in the August '87 issue and finally | Rubin's reply to Dijkstra in the December issue. | | [code deleted to appease inews] | | I think that the above code says it all... I would like to know if ANYONE | think Dijkstras program is easier to read [which IS the question, right?] | than Rubins? Not as written, but with a few alterations (like using more descriptive variable names, an if statement instead of the logical assignment in the inner loop, etc.) I would prefer the non-GOTO style. Really. ;') Whether or not GOTOs are acceptable is largely a matter of the kind of code you (and your coworkers!) are used to reading. I haven't used a GOTO for a very long time, and I actually had to take a second look at the GOTO version to understand how it worked. But even with the arbitrarily convuluted elements of Dijkstra's version, I knew how it worked at first glance. One thing the code samples you presented do *not* prove is the acceptability of GOTO code with jumps longer than a few lines. Sure, it's easy to see where a GOTO is leading when both the GOTO and it's target location appear right there on your 24-line screen, but when you are working on code of any significant size and complexity, the issue of knowing where the GOTO points to rears it's fugly head. For an example, pretend this article is a code segment. Now, quick, tell me where we're going... ;') goto LOCATION; -- char *david_sandberg() { return ( dts@quad.uucp || uunet!rosevax!sialis!quad!dts ); }