for <==> while (an exception)

Bill Vaughn bill at ur-cvsvax.UUCP
Tue Jul 16 04:03:53 AEST 1985


> > Section 3.5 of K&R (p. 56) states that the 'for' loop and 'while' loop
> > can be made equivalent....
> > 
> > Well ... almost.
> > If 'statement' contains a 'continue' statement, things may go awry.
> 
> If you look in the reference manual which is contained in K&R, you will see
> that the semantics of the continue statement are fully described in terms of
> equivalences among while, do-while, and for loops. Section 9.9 (p. 203) clears
> up the `exception' you perceive. Please bear in mind that the section that you
> quoted is part of a tutorial, and so all the gory details aren't presented at
> once or in the same place.
> -- 
> 	Marty Shannon

I'm not questioning the sematics of the continue statement in C (the necessity,
... well maybe), but I was simply pointing out that if anyone wanted to change
a 'for loop' to a 'while loop' he/she had better watch out for continue's.
By the way, the exception 'continues' to go unmentioned in section 9.6 and I
cannot see that it is brought up in section 9.9 either. (Maybe it was TOO gory
to bring up. :-)

	Bill Vaughn
	UUCP: {allegra,seismo,decvax}!rochester!ur-cvsvax!bill



More information about the Comp.lang.c mailing list