Path: utzoo!attcan!uunet!lll-winken!indri!nic.MR.NET!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: <140@quad.uucp> Date: 12 May 89 20:10:47 GMT References: <137@quad.uucp> <13507@lanl.gov> Reply-To: dts@quad.uucp (David T. Sandberg) Organization: Quadric Systems, Richfield MN Lines: 57 In article <13507@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >From article <137@quad.uucp>, by dts@quad.uucp (David T. Sandberg): >> >> Also, GOTOs can jump to any part of the program which they like: >> different functions, different modules, etc. [...] > >Maybe they can in C. But in MOST programming languages, a statement >label is _purely_ local. Not even Fortran allows GOTO to refer to a >non-local label (even with assigned GOTO this is illegal, but _some_ >old implementations allowed it). Okay, here I need to withdraw my earlier comments. I have *never* used a goto in C (the language I was basing my comments on), and wasn't aware that the scope rules limit the visibility of a label to the current function. I have since checked this and learned the truth. By way of explanation, the only languages I have ever used GOTOs in are BASIC (shudder) and assembly, both of which have jumps without scope limits; hence my incorrect assumption. Sorry. >> ........... but anyone who would use a global flag for controlling >> a conditional expression deserves what they get. > >Yes, but you don't have to evade the rules of the language to misuse >booleans in this way. Anyone who uses GOTO for inter-procedural transfer >deserves what they get too! I agree. >> [...] I hope I've convinced you that I sincerely would rather >> work with the structured version. > >So would I. BUT, since _both_ our versions were structured, the debate >seems to be bogged down on whether or not the "structured" version is >best. Okay, let me rephrase that - given your definitions, I would prefer to work with the "structured" version. However, I still wouldn't call the version with a GOTO a structured version, for the reason that, in my understanding, one of the main rules of structured programming is that there are only three structures - sequential, iterative, and conditional. The GOTO can be used to create those constructs, but it can also be used, even within the scope of one function, to create structures not qualifying as one of those three constructs which define structured programming. >"structured": eliminating GOTOs from code, even where the GOTO is the >most efficient method and is _AS_ readible and the proposed alternative.) Whether it is _AS_ readable as the GOTO-less version is obviously not an absolute, since I for one did not find it so. -- char *david_sandberg() { return ( dts@quad.uucp || uunet!rosevax!sialis!quad!dts ); }