prefers(x,y) visits ancestors by calling parents.invoke() recursively.
This visits the parents in the global hierarchy, not the multimethod's
Is this the intended behavior? Why would that be?
On the assumption that prefer-method should behave the same for a local vs
the global-hierarchy, below are 2 unit tests.
MultiFn-prefers-with-local-hierarchy fails with a "Multiple methods"
(let [h (make-hierarchy)
h (derive h ::c0 ::b0)
h (derive h ::d0 ::c0)
h (derive h ::d0 ::a0)]
(defmulti local identity :hierarchy #'local-hierarchy)
(defmethod local ::a0 [x] [::a0 x])
(defmethod local ::c0 [x] [::c0 x])
(prefer-method local ::b0 ::a0)
(test/is (= [::c0 ::d0] (local ::d0)))))
(derive ::c1 ::b1)
(derive ::d1 ::c1)
(derive ::d1 ::a1)
(defmulti global identity)
(defmethod global ::a1 [x] [::a1 x])
(defmethod global ::c1 [x] [::c1 x])
(prefer-method global ::b1 ::a1)
(test/is (= [::c1 ::d1] (global ::d1))))
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to email@example.com
Note that posts from new members are moderated - please be patient with your
To unsubscribe from this group, send email to
For more options, visit this group at
You received this message because you are subscribed to the Google Groups
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.