Re: for Iteration bug

From: Krzysztof Apt <apt_at_comp.nus.edu.sg>
Date: Sat 05 Mar 2005 02:41:21 AM GMT
Message-Id: <200503050241.KAA09127@sf0.comp.nus.edu.sg>
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.

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).
in which one has to pass the outer parameter (I) as param(I).
Am I right?

Regards,

Krzysztof

	From j.schimpf@icparc.ic.ac.uk  Fri Mar  4 23:10:25 2005
	Date: Fri, 04 Mar 2005 15:09:45 +0000
	From: Joachim Schimpf <j.schimpf@icparc.ic.ac.uk>
	User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-GB; rv:1.4) Gecko/20030701
	X-Accept-Language: en, en-us
	MIME-Version: 1.0
	To: Mark Wallace <Mark.Wallace@infotech.monash.edu.au>
	CC: eclipse-bugs@icparc.ic.ac.uk, Krzysztof Apt <apt@comp.nus.edu.sg>
	Subject: Re: for Iteration bug
	Content-Transfer-Encoding: 7bit

	Mark Wallace wrote:
	> In ECLiPSe Version 5.8 #78 (and earlier ECLiPSe releases), the following 
	> goal fails to halt:
	> ?- ( for(I,1,2), for(J,2,4) do writeln(I-J) )

	You mean "fails to fail" :-)


	The User Manual sort of says the right thing:

	"If several specifiers impose termination conditions, these conditions
	must coincide, i.e. specify the same number of iterations."

	but the Reference Manuals lies:

	"Fails if one of the Goals fails, or if two IterationSpecs specify
	a different number of iterations."

	I am afraid it would be an inacceptable overhead to resolve this
	in the sense of the Reference Manual because we'd have to precisely
	compute the 3-way split:

	All termination conditions true: stop
	All termination conditions false: continue
	Otherwise: fail


	-- 
	  Joachim Schimpf              /             phone: +44 20 7594 8187
	  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
	  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Sat Mar 05 02:43:15 2005

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