Found an answer on stackoverflow

http://stackoverflow.com/questions/4512790/how-do-i-use-print-dup-to-print-records-in-clojure-a-simple-case

On Dec 22, 1:27 pm, Brent Millare <brent.mill...@gmail.com> wrote:
> Hello,
>
> I'm trying to use *print-dup* to allow writing clojure data to a file
> and then read it back, however, I'm getting problems even with this
> simple case. Is there something I am doing wrong? What do I need to do
> to get this to work?
>
> Clojure 1.3.0-alpha3-SNAPSHOT
> user=> (defrecord TreeNode [val left right]) ;;create the record
> user.TreeNode
> user=> (TreeNode. 5 nil nil)
> #:user.TreeNode{:val 5, :left nil, :right nil} ;; it works just fine
> user=> (binding [*print-dup* true] (prn (TreeNode. 5 nil nil))) ;; use
> *print-dup* to support reading in and preserving type
> #=(user.TreeNode/create {:val #=(java.lang.Long. "5"), :left
> nil, :right nil}) ;; this is the form we need to copy paste
> nil
> user=> #=(user.TreeNode/create {:val #=(java.lang.Long. "5"), :left
> nil, :right nil}) ;;trying to copy and paste
> IllegalArgumentException No matching method found: create
> clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:50) ;;we
> have an error
> user=>

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

Reply via email to