for <==> while (an exception)

M.J.Shannon mjs at eagle.UUCP
Wed Jul 17 06:29:49 AEST 1985


> In article <200 at ur-cvsvax.UUCP> bill at ur-cvsvax.UUCP (Bill Vaughn) writes:
> >Section 3.5 of K&R (p. 56) states that the 'for' loop and 'while' loop
> >can be made equivalent i.e.
[ elided to save net cost ]
> >Are there any other exceptions?
> 
> Here's another ...
> An infinite "for" loop is given by "for (;;) statement".  The equivalent
> "while" expression is, logically, "while () statement".  As this fails to
> compile, one has to resort to "while (1) statement"; which is less efficient
> in most cases as code is generated to test if "1" equals "0".
> -- 
> UUCP:	...!seismo!mcvax!ukc!dcl-cs!stephen

To reiterate, the specification of the C language (at the time) is in the
Reference Manual, which is at the end of K&R.  The content of the rest of the
book is meant to be a tutorial.  What may seem logical conclusions from the
tutorial are spelled out (or disspelled) in great detail in the Reference
Manual.
-- 
	Marty Shannon
UUCP:	ihnp4!eagle!mjs
Phone:	+1 201 522 6063



More information about the Comp.lang.c mailing list