Racklog provides special predicates for probing logic variables, without risking their getting bound.
(%== X Y)
succeeds if X and Y are identical objects. This is not quite the unification predicate %=, for %== doesn’t touch unbound objects the way %= does. Eg, %== will not equate an unbound logic variable with a bound one, nor will it equate two unbound logic variables unless they are the same variable.
succeeds if X isn’t completely bound —
Racklog lets the user protect a term with variables from unification by allowing that term to be treated as a (completely) bound object. The predicates provided for this purpose are %freeze, %melt, %melt-new, and %copy.
(%freeze S F)
unifies F to the frozen version of S. Any lack of bindings in S are preserved no matter how much you toss F about. Frozen variables will only unify with themselves. For example, in the following query, even though x and y are unbound, their frozen counterparts a and b will not unify with each other:
However, we can unify a frozen variable with itself:
> (%which (x frozen y z) (%freeze (list x x) (list y z)) (%= y z))
'((x . _) (frozen . _) (y . #<frozen>) (z . #<frozen>))
(%melt F S)
retrieves the object frozen in F into S; the variables in S will be identical to those in the original object. For example:
> (%which (x frozen melted) (%freeze (list x x) frozen) (%melt frozen melted) (%= melted (list 2 2)))
'((x . 2) (frozen #<frozen> #<frozen>) (melted 2 2))
(%melt-new F S)
is similar to %melt, except that when S is made, the unbound variables in F are replaced by brand-new unbound variables, respecting the existing equivalences between them, for example:
> (%which (x y frozen a b c) (%freeze (list x x y) frozen) (%melt-new frozen (list a b c)) (%= a 'red) (%= c 'green))
'((x . _)
(y . _)
(frozen #<frozen> #<frozen> #<frozen>)
(a . red)
(b . red)
(c . green))
(%copy S C)