Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!brl-adm!seismo!mcvax!enea!zyx!bd From: bd@zyx.UUCP Newsgroups: comp.lang.prolog Subject: compare/3 problem Message-ID: <373@zyx.UUCP> Date: Thu, 26-Mar-87 21:10:21 EST Article-I.D.: zyx.373 Posted: Thu Mar 26 21:10:21 1987 Date-Received: Mon, 30-Mar-87 03:24:05 EST Reply-To: bd@zyx.UUCP (Bjorn Danielsson) Organization: ZYX Sweden AB, Stockholm Lines: 26 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