`eval` invokes the Clojure compiler, which transforms data structures into 
Java bytecode.  The Clojure compiler understands Clojure data structures 
like lists, vectors, and symbols, plus a few Java types like String and 
numbers.  It doesn't know what to do with a java.util.Date.  "Can't embed 
object in code" is the compiler telling you "I don't know what to do with 
this."

`print-dup` is an internal multimethod used by the Clojure compiler to 
transform complex objects, like sorted sets, into data structures 
representing the Clojure code to construct them.  For example,

user=>  (print-dup (sorted-set) *out*)
#=(clojure.lang.PersistentTreeSet/create [])

The #= is a Clojure reader macro that means "evaluate the following code."

The error message "maybe print-dup not defined" is suggesting that, if you 
really did mean to stick a java.util.Date in your compiled code, you have to 
provide your own implementation of print-dup.  Specifically, you need a 
method of print-dup that takes a java.util.Date and returns a data structure 
representing the Clojure code that *creates* a java.util.Date.  For example:

user=>  (defmethod print-dup java.util.Date [d stream]
          (.write stream "#=(java.util.Date. ")
          (.write stream (str (.getTime d)))
          (.write stream ")"))

user=>  (eval [(java.util.Date.)])
[#<Date Fri Mar 11 23:47:13 EST 2011>]

However, this is probably not what you really meant to do.  More likely, you 
have a macro or `eval` somewhere that is using code that is incorrectly 
quoted.

-Stuart Sierra
clojure.com

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