Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.6.2.16 $; site ada-uts.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!whuxl!whuxlm!akgua!gatech!seismo!lll-crg!lll-lcc!vecpyr!amd!pesnta!pyramid!decwrl!decvax!cca!ada-uts!richw From: richw@ada-uts.UUCP Newsgroups: net.lang.c Subject: Loop "Equivalencies" Message-ID: <10200026@ada-uts.UUCP> Date: Wed, 13-Nov-85 10:40:00 EST Article-I.D.: ada-uts.10200026 Posted: Wed Nov 13 10:40:00 1985 Date-Received: Wed, 20-Nov-85 07:48:27 EST Lines: 32 Nf-ID: #N:ada-uts:10200026:000:908 Nf-From: ada-uts!richw Nov 13 10:40:00 1985 I'd like to point out what I think is a bug in Kernighan & Ritchie. My version's copyright is 1978; please excuse this if I have an old version and newer versions (?) have fixed it. In Appendix A (C Reference Manual), p. 202, and p. 56, it says that the following: for (expr1; expr2; expr3) statement is equivalent to: expr1; while (expr2) { statement expr3; } This is not true if "statement" is a block which contains a "continue" since, in the first case, "expr3", is executed after the continue but is not in the second case. I came across this while working on someone else's code. This code constantly used the "while" form in places where I thought a "for" was more concise and appropriate. So, whenever I'd see the second "while" form, I'd transform it (based on this buggy K&R statement). Then I got burned... Am I missing something? -- Rich Wagner