Hi Stuart, When I try using deftype I get the following error: java.lang.IllegalArgumentException: No method in multimethod 'print- dup' for dispatch value: class user.Y__5
Do I have to supply my own print-dup for the new type for this to work? Here is the code: (import '(java.io StringReader PushbackReader)) (deftype Y [a b]) (defn serialize [x] (binding [*print-dup* true] (pr-str x))) (defn deserialize [x] (let [r (new PushbackReader (new StringReader x))] (read r))) (def y (Y "a" "b")) (deserialize (serialize y)) I'm thinking the easiest way to accomplish what I need is to serialize the structmaps as hashmaps when writing them, and then deserialize the hashmap into a new structmap when reading them. On Jan 26, 9:01 am, Stuart Sierra <the.stuart.sie...@gmail.com> wrote: > On Jan 26, 11:40 am, jleehurt <jleeh...@gmail.com> wrote: > > > Thanks Anders. I'm not sure why, but it appears that read does not > > support structmaps. > > That is correct, read does not work with structmaps, because it > doesn't know how to resolve the struct definition while reading. > > deftype, the replacement for structmaps, solves that problem. > > -SS -- 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