Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: are for loops and while loops the same thing? Message-ID: <715@umcp-cs.UUCP> Date: Sun, 6-Apr-86 01:30:07 EST Article-I.D.: umcp-cs.715 Posted: Sun Apr 6 01:30:07 1986 Date-Received: Wed, 9-Apr-86 07:04:50 EST References: <139@mit-amt.MIT.EDU> Reply-To: chris@maryland.UUCP (Chris Torek) Organization: University of Maryland, Dept. of Computer Sci. Lines: 40 Summary: No. In article <139@mit-amt.MIT.EDU> judith@mit-amt.MIT.EDU (Judith Donath) [asks yet another `frequently asked' question; perhaps this should be included in the net.announce.newusers section.] >K & R, page 56: > "The for statement > for (expr1; expr2; expr3) > statement > is equivalent to > expr 1; > while (expr2) { > statement > expr3; > }" > >Not always true. Correct. >K & R, page 62 > "The continue statement... causes the next iteration of the > enclosing loop (for, while, do) to begin. ..." Note that this is in the `tutorial' part of the book, and that page 62 comes after page 56. >Is there any reason or use for this difference in behaviour between >while and for? This is the way most people believe they should behave. >Are there any implementations in which a continue in a for loop >passes control to the test [...] ? If so, those implementations are incorrect. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu