From: Ari.Huttunen@hut.fi (Ari Juhani Huttunen)
Subject: Sather loops (was Re: Scientists as ...
Organization: Helsinki University of Technology, Finland
	<ARI.HUTTUNEN.92Aug30182130@hulk.hut.fi>
	<BEVAN.92Aug30182505@tiger.cs.man.ac.uk>
Date: Fri, 4 Sep 1992 00:18:32 GMT

! In article <ARI.HUTTUNEN.92Aug30182130@hulk.hut.fi> Ari.Huttunen@hut.fi (Ari Juhani Huttunen) writes:
!    Yes, I would myself like to see these loop-constructs in Sather:

!   loop       until <xxxx> loop   while <xxxx> loop  for <xxxx> to <yyyy> loop
!     <xxxx>     <yyyy>              <yyyy>             <zzzz>
!   end        end                 end                end

				   ^
				   |
				   | Forget that one.

! IMHO the above are quite poor syntax for expressing the kinds of loops
! that I see in numerical code.  Quite often it is possible to work in
! parallel, and all the above do is make it harder to extract the
! parallelism (of course so does the FORTRAN notation, but there is not
! reason to make the same mistake :-).

I can't know what kinds of loops you see in numerical code, so I can't
comment on that. I got the impression from the previous article that
a for-loop is wanted. Now it is not wanted?

As for the parallelism... You *do not* extract parallelism from
a sequential program. You design a parallel program. That is not
the same thing. Extracting parallelism from a sequantial loop does
not help 0.01 cents if the computer has 64000 processors and now
it uses 3 of them instead of 1.

!  In the cases where it is not
! numerical, syntax like the above is often useless as it is usually
! restricted so that you can only iterate over integer indices (cf
! Oberon-2).  Note some languages get this right and let you iterate
! over whatever you want e.g. Eiffel and C (given Sather's parentage I
! guess it does to) 

Sather has the same loop construct that Eiffel has, and it is written
on my list. The reason why I put the for-loop in the list is that it
is so common. Take a look at this piece of code from the Sather library:

      -- Clear out the array. 
      i:INT; until i=asize1 loop
	 j:INT; until j=asize2 loop
	    k:INT; until k=asize3 loop
	       [i,j,k]:=void;
	       k:=k+1;
	    end; -- loop
	    j:=j+1;
	 end; -- loop
	 i:=i+1; 
      end; -- loop

With the for-loop it becomes shorter and much easier to read. To see
what I mean, note that at the first sight, you look at the beginning 
of the rows and see 'for ...'. You immediately notice a keyword. In
contrast the above code has 'k:INT; ...' at the beginning. 

      -- Clear out the array. 
      for i:INT to asize1 loop
	 for j:INT to asize2 loop
	    for k:INT to asize3 loop
	       [i,j,k]:=void;
	    end; -- loop
	 end; -- loop
      end; -- loop

You wouldn't need the for-loop for iterating over the elements of a list
(for example), so it need not be overly general. The existing loop is
perfect for that. You could, however, have something like:

	for r=0.0 to 5.3 step 0.1 loop
		...
	end
--
...............................................................................
Ari Huttunen   			       Any similarity to other alien life forms
				          is purely coincidental.
					      <Alien 3 misquote>