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 <clojure@googlegroups.com>:

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



-- 
庄晓丹
Email:        killme2...@gmail.com xzhu...@avos.com
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.

Reply via email to