Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: goto's Message-ID: <7796@mimsy.UUCP> Date: Fri, 31-Jul-87 04:33:41 EDT Article-I.D.: mimsy.7796 Posted: Fri Jul 31 04:33:41 1987 Date-Received: Sat, 1-Aug-87 16:05:05 EDT References: <3289@bigburd.PRC.Unisys.COM> <7571@beta.UUCP> <765@haddock.ISC.COM> <105@rdlvax.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 42 In article <105@rdlvax.UUCP> kopaz@rdlvax.UUCP (John Anthony 'Echo' Kopaz) writes: [regarding mechanically removing goto statements by adding booleans] >i don't think all that warped boolean logic is in the best interest to >readable code. Certainly not. But someone made the claim that there are algorithms that require goto statements; this is not the case. On the other hand, modern imperative languages have all the constructs they do for good reason: You can write what you mean. Clear code requires two things: knowing what you mean; and writing that. If you *really mean* `go do something special', by all means, write that. But if you mean something that can be expressed *simply* (this is important) using a weaker construct (`weaker' here means `less able to affect control flow': `while' is weaker than `goto'), use the weaker form. It says less, and hence is easier to understand. A loop that reads while ((in = getinput()) != END_OF_INPUT) (*op[in])(in); is using a very strong control operation, yet may well be easier to understand than a whole series of weak `if's: while ((in = getinput()) != END_OF_INPUT) { if (in < 4) { ... } else if (in == 4) { ... } else if (in < 7) { ... } ... } Deciding when the stronger construct makes the code clearer is an art, and different people will certainly have different aesthetics. So what else is new? :-) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mimsy!chris