Re: [eclipse-users] Endless loop

From: Marco Gavanelli <marco.gavanelli_at_...17...>
Date: Wed, 10 Jan 2007 10:30:41 +0100
Philippe de Rochambeau wrote:
> Hello,
> 
> eclipse seems to go into endless loop when you type
> 
> X = f(X), Y = f(Y), X = Y.

This is something "you should not write" according to Prolog semantics :-)

In theory, X=f(X) should simply fail, because a variable cannot unify 
with a term containing the variable itself. But checking at every 
unification that the resulting term does not contain cycles is quite 
expensive, so most Prolog systems do not perform the check (by default).

In ECLiPSe, you can switch the occur-check on by setting the flag 
occur_check:

[eclipse 1]: set_flag(occur_check,on).

Yes (0.00s cpu)
[eclipse 2]: X = f(X), Y = f(Y), X = Y.

No (0.00s cpu)

So, you should write X=f(X) only if you have the occur-check activated; 
otherwise you know that you may get inconsistent results.

Cheers,
Marco

-- 
Marco Gavanelli, Ph.D.
Computer Science Division
Dipartimento di Ingegneria
University of Ferrara
Via Saragat 1 - 44100 Ferrara (Italy)
Tel  +39-0532-97-4833
Fax  +39-0532-97-4870
http://www.ing.unife.it/docenti/MarcoGavanelli/
Received on Wed Jan 10 2007 - 09:31:27 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST