Xref: utzoo comp.lang.modula2:1217 comp.lang.c:15825 Path: 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: <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 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