🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4609

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

#4609
From: Norman Diamond
Date: Mon, 30 Jan 1989 03:00
40 lines
2454 bytes
In article <19579@agate.BERKELEY.EDU>, bowles@eris.berkeley.edu (Jeff A. Bowles) writes:

[Praising C's for-loop over other languages' iterators]

>    If I had a nickel for every time, in Fortran,
>    that I needed a loop that ran from 0.0 to 1.0 by 0.1 (or the like) and
>    had to use INTEGER to do it.

If you do such iterations in floating-point, adding 0.1 each time
instead of multiplying an integer by 0.1, you will lose a lot of
nickels.  I wouldn't mind receiving them.  (The Vancouver Stock
Exchange did that kind of thing.  Eventually their computed index
of stock prices became about half of the correct value, and they
finally noticed they had a bug.)

>    Or Pascal, which lacked the "step" clause
>    so that you couldn't increment by more than what the language-designer
>    wanted.

This was not due to what the language designer wanted.  Remember that
he only had resources available for a small compiler and had to provide
maximal assistance to novice students in error checking.  Testing "for"
statements for overflow when the stepsize is not 1 is more difficult.
Now if you had complained that the modern version, i.e. the draft ISO
Extended Pascal standard, still doesn't allow it, then I would agree
with your complaint.

> The only thing I really miss is something you Unix-types will recognize
> from awk (and perhaps from Algol 68?) -
> 	for (t in table)
> 		process(table[t]);
> But that's another story....

Do you mean:  for (t in some_set) process (table[t]) ?
At least the draft Extended Pascal standard has this one.
-- 
Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.jp@relay.cs.net)
  The above opinions are my own.   |  Why are programmers criticized for
  If they're also your opinions,   |  re-inventing the wheel, when car
  you're infringing my copyright.  |  manufacturers are praised for it?
Technical Details
Message-ID: <10023@diamond.csl.sony.JUNET>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!ncar!ames!amdcad!sun!pitstop!sundc!seismo!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond
References: <INFO-M2%89011219330825@UCF1VM> <739@jupiter.iis.UUCP> <19579@agate.BERKELEY.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!ncar!ames!amdcad!sun!pitstop!sundc!seismo!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond
From: diamond@csl.sony.JUNET (Norman Diamond)
Newsgroups: comp.lang.modula2,comp.lang.c
Subject: Re: "for" loops (was Re: C++ vs. Modula2)
Message-ID: <10023@diamond.csl.sony.JUNET>
Date: 30 Jan 89 03:00:29 GMT
References: <INFO-M2%89011219330825@UCF1VM> <739@jupiter.iis.UUCP> <19579@agate.BERKELEY.EDU>
Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan
Lines: 40