Article View: comp.lang.modula2
Article #4585"for" loops (was Re: C++ vs. Modula2)
From: stepanek/cs assoc
Date: Thu, 26 Jan 1989 01:45
Date: Thu, 26 Jan 1989 01:45
39 lines
1953 bytes
1953 bytes
In article <739@jupiter.iis.UUCP> heiser@iis.ethz.ch (Gernot Heiser) writes:
>
>worst features. C's 'for' is really a 'while' with an initialization clause and
>a designated spot that may contain an incrementation clause. What I consider a
>"real" 'for' (as opposed to the while/repeat/loop family) is a construct that
>executes a specific number ot times, the iteration count being determined
>BEFORE the processing of the body starts. This is what is really needed most of
>the time in numerical programs. The other cases are exactly what while/repeat/
>loop constructs are for.
Actually, C's "for" can be duplicated EXACTLY by C's "do ... while" loops.
Consider:
for (i = 0; i <= 17; ++i)
{
stuff();
more_stuff();
}
versus:
i = 0;
do {
stuff();
more_stuff();
} while (++i <= 17);
These two iterations are indistinguishable from one another. The "for" term
in C is totally superfluous and is only included because it makes it look like
languages that have a more "for"-ish "for" statement, like Pascal or Modula.
(I won't even get into Algol's "for" here....)
--
Jeff Boeing: ...!csun.edu!csuna!abcscagz (formerly tracer@stb.UUCP)
--------------------------------------------------------------------------
"When Polly's in trouble I am not slow / It's hip, hip, hip and away I go!"
-- Underdog
Technical Details
Message-ID:
<1611@csuna.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!ames!ncar!boulder!sunybcs!rutgers!mit-eddie!bu-cs!mirror!rayssd!srhqla!csun!csuna!abcscagzReferences:
<INFO-M2%89011219330825@UCF1VM> <739@jupiter.iis.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!ames!ncar!boulder!sunybcs!rutgers!mit-eddie!bu-cs!mirror!rayssd!srhqla!csun!csuna!abcscagz From: abcscagz@csuna.UUCP (stepanek/cs assoc) Newsgroups: comp.lang.modula2,comp.lang.c Subject: "for" loops (was Re: C++ vs. Modula2) Message-ID: <1611@csuna.UUCP> Date: 26 Jan 89 01:45:52 GMT References: <INFO-M2%89011219330825@UCF1VM> <739@jupiter.iis.UUCP> Reply-To: abcscagz@csuna.csun.edu (Jeff Boeing) Organization: California State University, Northridge Lines: 39