pop@cs.umass.edu (02/14/91)
While purists would consider it an error, the fact that Prolog implementations do not include an occurs check in unification makes it possible to create cyclic data-structures, e.g. :- X = [a|X]. will succeed, creating an infinite list of a's. Whethere there is a breed of Prolog programmers who happily knit up tangled webs in this way, I don't know, nor is it entirely obvious to me how to program up the example that Russell Turpin refers to. The spouse "slot" could be put in a tree by having a unique unbound variable at each node, which is no great problem. However any attempt at a recursive traversal of the tree to fill in the spice would not work, since the variables would be unbound as soon as each recursive sub-goal succeeded. I think that one would have to write a tail-recursive predicate, which explored the tree by maintaining an explicit stack. At the end of all the binding, it could only be preserved by using an assert..