Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.unify by

In the cond in the occurs? function, this condition:

(zip/end? z) false

appears twice. Unless I very much misunderstand, the second clause will never succeed.

Also, I'm wondering if it makes sense (in core.unify) for composite? to be true for strings. It looks like this means occurs? will futilely check each character of a string looking for variables.

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/UNIFY-7 (reported by glchapman)
by
Referring to comments added to the JIRA issue:

Thank you for fixing the dead code. As to strings resolving as true in composite?, look again and you'll see a `(string? x)` test in the composite? function. My expectation was that the following would not unify (that "foo" would be treated as atomic):


    user=> (require '[clojure.core.unify :as u])
    nil
    user=> (u/unify '[?x ?y ?z] "foo")
    {?x \f, ?y \o, ?z \o}


However, I can see that changing it now might be considered a breaking change and so not worth it.
...