Toy compilers (was Re: gotos)

Larry Campbell campbell at maynard.BSW.COM
Tue May 3 12:24:06 AEST 1988


In article <504 at wsccs.UUCP> terry at wsccs.UUCP (Every system needs one) writes:
<>                   ...  I happen to write code that uses
<>
<>	for( ;;) {
<>	}
<>
<>instead of
<>
<>	while( 1) {
<>	}
<>
<>too, as I need the best speed out of the hardware I can get and the 'for'
<>avoids a test instruction being generated.  Certainly, the 'while' is better
<>at self-documenting, but it isn't the right tool for the job.

For someone who believes in using the right tool for the job, you seem
to have chosen a pathetically lame compiler.  The compiler should generate
the same code in both cases, since (1) is obviously a compile-time
constant expression.

It's penny-wise and pound-foolish to buy a toy compiler, and then feel
compelled to write code like the above.  In the long run, the
maintenance and support costs you incur will vastly overshadow the few
hundred dollars you might have saved by skimping on the compiler.

P.S. -	I just compiled a "while (1)" loop on my system, which has one
	of the wimpier C compilers around.  It generated the right code
	(i.e., no test instructions, just a jump to the top of the loop).
	And this was without -O.
-- 
Larry Campbell                                The Boston Software Works, Inc.
Internet: campbell at maynard.bsw.com          120 Fulton Street, Boston MA 02109
uucp: {husc6,mirror,think}!maynard!campbell         +1 617 367 6846



More information about the Comp.lang.c mailing list