Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!purdue!i.cc.purdue.edu!k.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.lang.c Subject: Re: gotos Message-ID: <748@l.cc.purdue.edu> Date: 12 Apr 88 12:16:38 GMT References: <1988Apr8.183815.3187@utzoo.uucp>, <449@goofy.megatest.UUCP> <1988Apr11.201934.20594@utzoo.uucp> Organization: Purdue University Statistics Department Lines: 23 Summary: Do this reasonably without gotos 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;}; 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. How else would you do it? -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu (ARPA or UUCP) or hrubin@purccvm.bitnet