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=>
As an update, as of alpha8, in the simple case, *print-dup* with records now works.