🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4586

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

#4586
From: John Hascall
Date: Fri, 27 Jan 1989 14:38
27 lines
1640 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
 ^^^^^^

  I can't count the number of times this has nailed C novices who have had
  experience with other languages (i.e., FORTRAN).
  For example:

      for ( i=0; i < fn_with_side_effects(x); i++ ) {
	  blue_dog_moon_up();
      }

>the time in numerical programs. The other cases are exactly what while/repeat/
>loop constructs are for.

    As far as I can see, the main purpose of C's "for" is to save space,
    which is one of C's strengths (to some, probably not to MIS/COBOL
    types [oh! sorry, this isn't the misc.jobs.misc C/COBOL-CS/MIS
    flamewar?])

    John Hascall
    ISU Comp Center
Technical Details
Message-ID: <738@atanasoff.cs.iastate.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!ames!mailrus!sharkey!atanasoff!hascall
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!attcan!uunet!lll-winken!ames!mailrus!sharkey!atanasoff!hascall
From: hascall@atanasoff.cs.iastate.edu (John Hascall)
Newsgroups: comp.lang.modula2,comp.lang.c
Subject: Re: "for" loops (was Re: C++ vs. Modula2)
Message-ID: <738@atanasoff.cs.iastate.edu>
Date: 27 Jan 89 14:38:41 GMT
References: <INFO-M2%89011219330825@UCF1VM> <739@jupiter.iis.UUCP> <1611@csuna.UUCP>
Reply-To: hascall@atanasoff.cs.iastate.edu (John Hascall)
Organization: Iowa State U. Computer Science Department, Ames, IA
Lines: 27