Given the definitions:

(defmulti foo class)
(defmethod foo clojure.lang.IPersistentCollection [_] :a-collection)
(defmethod foo clojure.lang.IPersistentVector [_] :a-vector)

one obtains the following results:

(foo [1 2 3])  -> :a-vector
(foo #{1 2 3}) -> :a-collection

This looks perfectly logical from an OO point of view, but I cannot  
find anything in the documentation (http://clojure.org/multimethods)  
that actually promises that the vector implementation of foo takes  
precedence over the generic collection version if the argument is a  
vector. Can I rely on that or should I add

(prefer-method foo clojure.lang.IPersistentVector  
clojure.lang.IPersistentCollection)

explicitly?

Konrad.

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to