gotos

Herman Rubin cik at l.cc.purdue.edu
Tue Apr 12 22:16:38 AEST 1988


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 at l.cc.purdue.edu (ARPA or UUCP) or hrubin at purccvm.bitnet



More information about the Comp.lang.c mailing list