Hi Dennis, when I quote the whole vector for let, the function that defines the symbol D is called while evaluating the eval form.
But in the context I want to use the object bound to the symbol, the object has to be generated outside of eval and just be used in eval replacing the symbol D in f. Burt Am Donnerstag, 30. März 2017 10:09:20 UTC+2 schrieb dennis: > > You should quote the binding vector: > > (let [v '[D (LocalDate/of 2017 03 30)] > f '(.getYear D)] > (eval `(let ~v ~f))) > > > > 2017-03-30 16:04 GMT+08:00 'Burt' via Clojure <clo...@googlegroups.com > <javascript:>>: > >> Hi, >> >> I want to pass Java objects to a piece of code via let and then get it >> evaluated with eval. >> >> An minimal example: >> >> (ns eval >> (:import (java.time LocalDate))) >> >> (let [v ['S (String. "ab")] >> f '(.length S)] >> (eval `(let ~v ~f))) >> >> ; => 2 >> >> (let [v ['D (LocalDate/of 2017 03 30)] >> f '(.getYear D)] >> (eval `(let ~v ~f)))) >> >> ; => CompilerException java.lang.RuntimeException: Can't embed object in >> code, maybe print-dup not defined: 2017-03-30 >> >> >> The first example with String works fine and is what I want to do. >> >> >> But if I transfer the example to other Java classes, for example LocalDate I >> get an error, see the second example. >> >> >> Can anybody help? >> >> >> Kind regards, >> >> Burt >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com >> <javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > 庄晓丹 > Email: killm...@gmail.com <javascript:> xzh...@avos.com > <javascript:> > Site: http://fnil.net > Twitter: @killme2008 > > > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.