gotos

00704a-Liber nevin1 at ihlpf.ATT.COM
Sat Apr 16 08:24:14 AEST 1988


First off Herman, I want to thank you for giving an example of why GOTO's
should NOT be used indiscriminately!

In article <748 at l.cc.purdue.edu> cik at 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."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah



More information about the Comp.lang.c mailing list