🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4597

Re: "for" loops (was Re: C++ vs. Modula2)

#4597
From: stepanek/cs assoc
Date: Sat, 28 Jan 1989 22:38
31 lines
1608 bytes
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)
       <stuff>;

versus:

    i = 0;
    while (i <= 17)
    {
        <stuff>;
        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
Technical Details
Message-ID: <1626@csuna.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pasteur!ucbvax!hplabs!sm.unisys.com!csun!csuna!abcscagz
References: <INFO-M2%89011219330825@UCF1VM> <739@jupiter.iis.UUCP> <1611@csuna.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <INFO-M2%89011219330825@UCF1VM> <739@jupiter.iis.UUCP> <1611@csuna.UUCP>
Reply-To: abcscagz@csuna.csun.edu (Jeff Boeing)
Organization: California State University, Northridge
Lines: 31