or:- local reference(p).
creates a named reference p (with an initial value of 0) which can be used to store references to terms. This reference is accessed and modified in the same way as non-logical variables, with setval/2 and getval/2, but the following points are different for references::- local reference(p, 0).
[eclipse 1]: local reference(a), variable(b). yes. [eclipse 2]: Term = p(X), setval(a, Term), getval(a, Y), Y == Term. X = X Y = p(X) Term = p(X) yes. [eclipse 3]: Term = p(X), setval(b, Term), getval(b, Y), Y == Term. no (more) solution.
[eclipse 4]: setval(a, 1), (setval(a, 2), getval(a, X); getval(a, Y)). X = 2 Y = Y More? (;) X = X Y = 1