Re: for Iteration bug

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Mon 07 Mar 2005 05:41:17 PM GMT
Message-ID: <422C923D.7030503@icparc.ic.ac.uk>
Krzysztof Apt wrote:
 > Hi Joachim,
 >
 > Well, the problem is that
 >
 > ( for(I,1,2), for(J,2,4) do writeln(I-J) )   (A)
 > and
 > ( foreach(I,[1,2]), foreach(J,[2,3,4]) do writeln(I-J) ).
 > behave differently, which should not be the case.

I agree that this is unsatisfactory.


 >
 > Sth else.
 >
 > In Modula and Algol-like languages we can write
 >
 > FOR i:=1 TO N DO
 >   FOR j:=1 TO M DO
 >     ...
 >   END
 > END
 >
 > and this is just a nested for-loop. I assume that the right
 > way to write it in Eclipse is *only* with *nested* for loops
 > and not iterated ones (like in line (A) above).

Just about terminology: I wouldn't call the combination in (A)
"iterated" (as opposed to nested), but rather "simultaneous" or
"lockstep" (after P.Schachte) since you are iterating over two
or more indices simultaneously in one loop (something you can't
write directly with Algol-style loops).


 > in which one has to pass the outer parameter (I) as param(I).
 > Am I right?

As Kish already mentioned, since the last release we have the multifor
iterator which can replace the specific case of nested for, and Warwick
is currently working on a more general way of doing these things.


-- Joachim
Received on Mon Mar 07 17:41:18 2005

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:08:25 PM GMT GMT