Xref: utzoo comp.lang.modula2:1228 comp.lang.c:15870 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pasteur!ucbvax!hplabs!sm.unisys.com!csun!csuna!abcscagz From: abcscagz@csuna.UUCP (stepanek/cs assoc) Newsgroups: comp.lang.modula2,comp.lang.c Subject: Re: "for" loops (was Re: C++ vs. Modula2) Message-ID: <1626@csuna.UUCP> Date: 28 Jan 89 22:38:05 GMT References: <739@jupiter.iis.UUCP> <1611@csuna.UUCP> Reply-To: abcscagz@csuna.csun.edu (Jeff Boeing) Organization: California State University, Northridge Lines: 31 Hoo boy, did I ever mess up in my last posting. I forgot that a C "for" loop may be executed zero times. So, let me rephrase my conviction that a C "for" loop is superfluous because it can be replaced by an equivalent "while" loop, NOT an equivalent "do ... while" loop: for (i = 0; i <= 17; i = sqr(i) + 2) ; versus: i = 0; while (i <= 17) { ; i = sqr(i) + 2; } There. I hope I have redeemed myself in the face of my previous blasphemy. And now that I think about it, it IS nice to have final incrementational conditions in the loop declaration rather than at the end of the loop-body, as the "while" case forces you to do. (Although I do still believe that the initial "statement" field of a "for" loop is superfluous.) -- Jeff Boeing: ...!csun.edu!csuna!abcscagz (formerly tracer@stb.UUCP) -------------------------------------------------------------------------- "When Polly's in trouble I am not slow / It's hup, hup, hup and awaay I go!" -- Underdog