🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #880

Re: FOR loops

#880
From: Aubrey McIntosh
Date: Wed, 04 Jul 1990 17:53
49 lines
2699 bytes
In article <1990Jul4.074634.645@diku.dk> jensting@skinfaxe.diku.dk (Jens Tingleff) writes:
>ROSS@UCF1VM.BITNET (Bri) writes:
>the loop-cntr. var a register var...... .
>
>By The Way, new question :
>  Is the FOR loop control var defined after the FOR statement ? Wirth
>  (PIM2 ed 3 p 158) doesn't say not, in fact the paragraph reads
>
> 	"FOR v := S TO B BY C DO SS END
>	 expresses repeated execution of the stat. seq. SS with
>	 v successively assuming the values A, A+C, A+2C, ..,
>	 A+nC where A+nC is the last term not exceeding B."
>	apologies to  Dire Straits 

At the same talk, at Stride Faire, Reno, 1985 (?) Wirth discussed this
in the context of 'be careful both of what the standard says, and what
it remains silent on.'

He went on to say that many implementors and programmers assume that
this standard requires the "consecutive," i.e. monotonic assignment of
values to v.  He specifically stated that such requirement is not anywhere
in his definitions, and it would be just as fine to do all the even
numbers first, then the odd numbers.  Part of his point was that, it
cannot be defined what the last value of v was during execution.  Any
compiler that assigns each correct value to v and executes the loop once
for that value would be legal.

In terms of reconciling why he would do that, I model in my mind that
he would want a correctly written matrix multiply program to compile and
run on a parallel machine, and leaving the execution order undefined
allows one to build (in principle) a compiler to parcel out the various
jobs for each loop to the available processors.

Again, he seemed to consider his definitions important not only on what they
do say, but equally on what avoid saying.

-------------------

I am writing what I remember from several years ago.  My memory may be
faulty, and Wirth surely has a more refined idea on many topics now than
he did then (he says so in his Oberon article, so I'm safe in saying that.)
I surely welcome having sharp minds try to pick apart what I've written,
but be nice so I'll read it.

-- 
Aubrey McIntosh  	"Find hungry samurai." -- The Old Man        
1502 Devon Circle       comp.os.minix, comp.lang.modula2         
Austin, TX 78723 
1-(512)-452-1540  (v)
Technical Details
Message-ID: <18443@rpp386.cactus.org>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!execu!sequoia!rpp386!aubrey
References: <INFO-M2%90070316593556@UCF1VM.BITNET> <1990Jul4.074634.645@diku.dk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!execu!sequoia!rpp386!aubrey
From: aubrey@rpp386.cactus.org (Aubrey McIntosh)
Newsgroups: comp.lang.modula2
Subject: Re: FOR loops
Message-ID: <18443@rpp386.cactus.org>
Date: 4 Jul 90 17:53:01 GMT
References: <INFO-M2%90070316593556@UCF1VM.BITNET> <1990Jul4.074634.645@diku.dk>
Reply-To: aubrey@rpp386.UUCP (Aubrey McIntosh)
Organization: vima, Austin TX
Lines: 49