Path: utzoo!attcan!uunet!yale!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.misc Subject: Re: The "evil" GOTO (Was: 25 Years of BASIC) Message-ID: <13507@lanl.gov> Date: 12 May 89 03:21:48 GMT References: <137@quad.uucp> Organization: Los Alamos National Laboratory Lines: 59 From article <137@quad.uucp>, by dts@quad.uucp (David T. Sandberg): > [...] > The "fan out" of a GOTO may be one, but the "fan in" of that GOTO's > label is unbounded (any number of GOTOs can use it as an entry point). Which is _exactly_ what I said in my posting. I also pointed out that the "fan-in" of booleans is _also_ unbounded. > 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). > [...] On the other hand, > a flag is almost always set within the function of it's usage (or > at least passed in as a parameter). [...] But, unlike GOTOs, a boolean _CAN_ be be passed around as a global! The language (any language) will permit the occurance. This is _not_ true of labels (which, as I've said before, are _required_ to be local by most programming languages). > [...] You could counter that using > a global flag would create the same kind of problem as GOTOs are > subject to, 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! > |Now, in truth, the 'fan-in' of a boolean and a label are exactly > |of the same complexity. Selecting mnemonic identifiers for either > |will increase readibility. So will the presence of appropriate > |comments. > > No, the "fan-in" of a *global* boolean and a label are exactly of the > same complexity. A local flag (the common & preferred method) has a > much more restricted scope. Repeatedly saying this doesn't make it true. A label has exactly the _SAME_ scope as a local variable. A flag _CAN_ be given global scope. A label _CAN'T_ be given global scope (look it up - Pascal, Modula, Ada, ALGOL, not even Fortran). > [...] 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. (Definitions - structured: code developed by stepwise refinement using (ultimately) whatever low-level programming tools that are available. "structured": eliminating GOTOs from code, even where the GOTO is the most efficient method and is _AS_ readible and the proposed alternative.)