Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 +2.11; site dcl-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!mcvax!ukc!icdoc!dcl-cs!stephen From: stephen@dcl-cs.UUCP (Stephen J. Muir) Newsgroups: net.lang.c Subject: Re: for <==> while (an exception) Message-ID: <314@dcl-cs.UUCP> Date: Sun, 14-Jul-85 19:17:28 EDT Article-I.D.: dcl-cs.314 Posted: Sun Jul 14 19:17:28 1985 Date-Received: Thu, 18-Jul-85 02:48:08 EDT References: <200@ur-cvsvax.UUCP> Reply-To: stephen@dcl-cs.UUCP (Stephen J. Muir) Distribution: net Organization: Department of Computing at Lancaster University. Lines: 23 Xpath: icdoc ivax In article <200@ur-cvsvax.UUCP> bill@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. > > expr1; >for (expr1; expr2; expr3) while (expr2) { > statement <==> statement > expr3; > } > >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 DARPA: stephen%lancs.comp@ucl-cs | Post: University of Lancaster, JANET: stephen@uk.ac.lancs.comp | Department of Computing, Phone: +44 524 65201 Ext. 4599 | Bailrigg, Lancaster, UK. Project:Alvey ECLIPSE Distribution | LA1 4YR