You need to quote the vector so the date will be created inside eval, instead of having the date go into eval as an element of the (evaluated) vector.
user=> (eval '[(java.util.Date.)]) [#<Date Fri Mar 11 19:59:31 PST 2011>] On Mar 11, 4:37 pm, Jeffrey Schwab <j...@schwabcenter.com> wrote: > What does eval'ing a form containing an object reference cause an > exception? What am I doing wrong? > > user=> (eval [(java.util.Date.)]) > java.lang.RuntimeException: Can't embed object in code, maybe print-dup not > defined: Fri Mar 11 19:33:04 EST 2011 (NO_SOURCE_FILE:153) > > This is the simplest example could contrive, but in the real code, I'm > trying to rename a bunch of files. I have two sequences of File objects; I > build up a list of commands in a do block, then try to eval it. I am using > eval because I want to inspect the whole form at the REPL before evaluating > it. > > user=> (eval [1]) > [1] > user=> (eval (java.util.Date.)) > #<Date Fri Mar 11 19:31:33 EST 2011> > > user=> (doc print-dup) > ------------------------- > clojure.core/print-dup > nil > nil > nil -- 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