bd@zyx.UUCP (03/27/87)
In the process of implementing Prolog, I and the people I am working with have been considering the problem of comparing variables with compare/3. The goal is that two variables should always be sorted in the same order, as long as their bindings don't change. In an implementation that is based on a Warren Abstract Machine, the natural way to compare variables is to compare their addresses. This normally sorts older variables to be < newer ones. However, it occurred to us that put_unsafe_value might cause problems with permanent variables (in Warren's terminology) that become globalized. Try the following program on your favourite WAM-based Prolog: test :- foo(X), bar(X). foo(X) :- compare(Z,Y,X), compare(Z,Y,X). bar(_). The query "?- test." should preferably succeed. (It didn't on one of the commercially available, widely popular Prologs we tried :-) The obvious fix is to let compare/3 globalize variables. -- Bjorn Danielsson, ZYX, +46 8 653205, ...mcvax!enea!zyx!bd
alain@kulcs.UUCP (Alain Callebaut) (04/24/87)
> become globalized. Try the following program on your favourite > WAM-based Prolog: > > test :- foo(X), bar(X). > foo(X) :- compare(Z,Y,X), compare(Z,Y,X). > bar(_). > > The query "?- test." should preferably succeed. (It didn't on one > of the commercially available, widely popular Prologs we tried :-) > > The obvious fix is to let compare/3 globalize variables. I tried this on my favourite WAM-based Prolog (which is BIM-Prolog). As you prefer, "?- test." did SUCCEED. Perhaps you can also try the following program : test :- write(_x), write(_x) . Now, "?- test." should write twice the same numbered variable. (In BIM-Prolog it does.) So, should write/1 (and many others) also globalizLveritar(,Y,e