RE: is s/and different inside an s/fdef?
Thanks Sean, I had't realized this was the case. I was fooled by the fact that conformed values often are the same as the unconformed value. That changed in the fdef where the the arg is enclosed in a seq. My spec setup didn't work as is, but the work around (s/cat :arg ::my spec) as the first predicate in the s/and worked. --Scott -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
MultiFn.prefers() ignores the multimethod's internal hierarchy
prefers(x,y) visits ancestors by calling parents.invoke() recursively. This visits the parents in the global hierarchy, not the multimethod's hierarchy. 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" IllegalArgumentException. MultiFn-prefers-with-global-hierarchy succeeds. (test/deftest MultiFn-prefers-with-local-hierarchy (def local-hierarchy (let [h (make-hierarchy) h (derive h ::c0 ::b0) h (derive h ::d0 ::c0) h (derive h ::d0 ::a0)] h)) (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) (test/deftest MultiFn-prefers-with-global-hierarchy (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 clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Question about transitivity in MultiFn.prefers() --- possible bug
prefers(x,y) checks the ancestors of x, and returns true if any of them are preferred to y --- which makes sense to me. However, it also check the ancestors of y, and returns true if x is preferred to any of them, which I don't understand. Is that the intended behavior? Seems like it should be checking the descendants of y. What I am I missing? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.