Path: utzoo!mnetor!uunet!ncc!alberta!att-ih!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.c Subject: Re: gotos Message-ID: <4441@ihlpf.ATT.COM> Date: 15 Apr 88 22:24:14 GMT References: <1988Apr8.183815.3187@utzoo.uucp> <449@goofy.megatest.UUCP> <1988Apr11.201934.20594@utzoo.uucp> <748@l.cc.purdue.edu> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 52 First off Herman, I want to thank you for giving an example of why GOTO's should NOT be used indiscriminately! In article <748@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >Here is a challenge to the denigrators of goto. I present a short fragment of >code; this code should be modified if right shifts are negative left shifts, >but the problems are the same. >Case 5: b >>= g16; > m |= b; > x = *(--geom); > if (TEST) > {if(ODD(x)) goto Case2; else goto Case1;}; > else {g4 = (x+1)/2; if(ODD(x)) goto Case3; else goto Case4;}; You should enter the whole program in the Obfuscated C contest! As long as it's under 1536 characters, it's sure to win!! :-) If you can't enter it, wait for the BASIC-disguised-as-C Contest! :-) >I claim that this construction is easily understood, except possibly by those >who are anti goto, and is efficient code. TEST involves a random bit, and >geom is a pointer to a random quantity, so that one can not anticipate the >values. Also each of the Cases 1-4 are more likely to be reached in other >ways than from Case 5. I cannot, simply by looking at it, tell what it's supposed to do. 60% or more of the work of programming should go into design and NOT coding, as it seems like it was done here. >How else would you do it? I don't know. If I had a good design spec of what the *whole* program is supposed to do I could probably write it in a C-like readable fashion without using a single GOTO. But don't expect me to rewrite a code fragment which is obviously totally dependent on GOTOs. Off the subject: For those of you who don't read comp.lang.misc: Herman has claimed that he can write a much better language than anything we have now, provided he can find someone to write the compiler for him. I, among others, have volunteered my time to help him on his quest and we are waiting for him to finish his *formal* detailed description of the language. So please don't bother him until *after* he completes this historical document. He's keeping the whole world on hold!! -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_