;;;;;;;;;;;
user=> (ancestors String)
#{java.io.Serializable java.lang.Object java.lang.CharSequence
java.lang.Comparable}
user=> (ancestors Object)
nil
user=> (derive String ::foo)
nil
user=> (derive Object ::bar)
nil
user=> (isa? String ::foo)
true
user=> (isa? String ::bar)
true
user=> (ancestors String)
#{java.io.Serializable java.lang.Object java.lang.CharSequence :user/
foo java.lang.Comparable}
user=> (ancestors Object)
#{:user/bar}
;;;;;;;;;;;
I'd expect that ::bar would be included in the set returned by
(ancestors String). A similar interaction involving only keywords:
;;;;;;;;;;
user=> (derive ::p ::gp)
nil
user=> (derive ::c ::p)
nil
user=> (ancestors ::c)
#{:user/p :user/gp}
;;;;;;;;;;
I'll open an issue with a patch if I'm correct in thinking that the
current behaviour of ancestors isn't correct in not including the tag
ancestors of superclasses.
- Chas
(defn ancestors
([tag] (ancestors global-hierarchy tag))
([h tag] (not-empty
(let [ta (get (:ancestors h) tag)]
(if (class? tag)
(let [superclasses (set (supers tag))]
(apply clojure.set/union
ta
superclasses
(map #(get (:ancestors h) %) superclasses)))
ta)))))
- Chas