Re: Prologs with Occurs Check constantly on?



On 2011-10-12, Jan Burse <janburse@xxxxxxxxxxx> wrote:
Jan Wielemaker schrieb:
SWI-Prolog after

set_prolog_flag(occurs_check, true).

Something else: I was thinking of a compile time
based occurs_check on/off thing, because it could be
applied selectively to code.

So instead of a flag that would affect the runtime,
if we had a flag that would affect the compile time,
we could for example compile certain modules without
occurs check and others with occurs check.

:- set_prolog_flag(clause_unify_checked, on).

/*
code where we want to have occurs check on
goes here.
*/

:- set_prolog_flag(clause_unify_checked, off).

In general that is a good idea, but in this particular case it is less
clear :-(

As Ulrich pointed out, the world of unification with occurs-check
combines poorly with the world of cyclic terms. This was the main
conclusion from a debate whether A=f(A), unify_with_occurs_check(A,_)
should succeed or fail.

Just making part of the code emit safe unification instructions is a
neat idea, but will only make sense if the control-flow can guarantee
that the terms entering this code are cycle-free and that the safe
code does not call unsafe code somewhere. That requires much than
simply emitting different unification instructions.

Cheers --- Jan
.