Have a look at clojure/core_print.clj in the clojure source. It is
indeed used with serialization - see print-dup. Here's an example of
usage;
(import '(java.io File FileWriter PushbackReader FileReader))
(defn rec-save
"Save a clojure form to file. Returns the called form."
[#^File file frm]
(with-open [w (FileWriter. file)]
(binding [*out* w *print-dup* true] (prn frm))) frm)
(defn rec-load
"Load and return a clojure form from a file."
[#^File file]
(with-open [r (PushbackReader. (FileReader. file))]
(let [rec (read r)]
rec)))
(rec-save (File. "my.clj-ser") {:a 1 :b "two"})
File "my.clj-ser" then contains...
#=(clojure.lang.PersistentArrayMap/create {:a 1, :b "two"})
(def rec (rec-load (File. "my.clj-ser")))
rec ==> {:a 1, :b "two"}
-Regards, Adrian.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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