Looking at the source of isa? it very specifically calls out vector arguments so I'd say it's by design.
Be careful that (isa? '(String foo) '(String foo)) returns true - child equal
to parent regardless of type.
(defn isa?
"Returns true if (= child parent), or child is directly or indirectly derived
from
parent, either via a Java type inheritance relationship or a
relationship established via derive. h must be a hierarchy obtained
from make-hierarchy, if not supplied defaults to the global
hierarchy"
{:added "1.0"}
([child parent] (isa? global-hierarchy child parent))
([h child parent]
(or (= child parent)
(and (class? parent) (class? child)
(. ^Class parent isAssignableFrom child))
(contains? ((:ancestors h) child) parent)
(and (class? child) (some #(contains? ((:ancestors h) %) parent) (supers
child)))
(and (vector? parent) (vector? child)
(= (count parent) (count child))
(loop [ret true i 0]
(if (or (not ret) (= i (count parent)))
ret
(recur (isa? h (child i) (parent i)) (inc i))))))))
On Mar 1, 2014, at 4:08 PM, Dave Tenny <[email protected]> wrote:
> (isa? [String String] [Object Object]) returns true. This is nice and useful.
>
> However
>
> (isa? '(String String) '(Object Object) returns false, this is not so nice.
>
> (isa? '(String String) [Object Object]) also return false.
>
>
> So the moral of the story is that for multiple argument dispatch to work, I
> need to use 'mapv' instead of 'map' in my dispatch function, which I have
> done.
> But it was sort of a pain to find out the hard way (i.e. time spent
> debugging) that 'map' won't work in this regard.
>
> I.e. this fails:
>
> (defmulti foo (fn [ & args ] (map class args)))
> (defmethod foo [Object Object] [a b] (println a b))
> (foo "a" "b")
> IllegalArgumentException No method in multimethod 'foo' for dispatch value:
> clojure.lang.LazySeq@86465241 clojure.lang.MultiFn.getFn (MultiFn.java:160)
>
> but this works:
>
> (defmulti bar (fn [ & args ] (mapv class args)))
> (defmethod bar [Object Object] [a b] (println a b))
> (bar "a" "b")
> a b
>
> Bug or feature?
>
> Clojure 1.5.1
>
signature.asc
Description: Message signed with OpenPGP using GPGMail
