I would like to print sorted maps readably (otherwise my sorted maps when printed and read back get turned into the default map), so I tried this:
(defmethod print-method clojure.lang.PersistentTreeMap [o, #^java.io.Writer w] (let [eprint (fn eprint [e sep?] (do (print-method (key e) w) (.write w " ") (print-method (val e) w) (if sep? (.write w ",") )))] (.write w (if *print-readably* "#=(sorted-map " "{")) (loop [s (seq o)] (if (rest s) (do (eprint (first s) true) (recur (rest s))) (eprint (first s) nil))) (.write w (if *print-readably* ")" "}")))) But when I try to prefer this: (prefer-method print-method clojure.lang.PersistentTreeMap clojure.lang.IPersistentMap) I get an exception because clojure.lang.IPersistentMap is already preferred to clojure.lang.PersistentTreeMap. Questions: Where does the preference for IPersistentMap come from? Is it from the following in boot.clj: (prefer-method print-method clojure.lang.IPersistentMap java.util.Map) since PersistentTreeMap is a java.util.Map? Is there a work-around to allow what I'm trying to do? Can MultiFn be changed to allow inspection of the preferTable? I'm thinking something like (get-prefers multifn) which would return the preferTable to help with diagnosing problems such as the above. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---