Re: Java object in eval

2017-03-30 Thread 'Burt' via Clojure
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

Re: Java object in eval

2017-03-30 Thread dennis zhuang
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 : > Hi, > > I want to pass Java objects to a piece of code via let and then get it > evaluated with eval. > > An minimal examp

Java object in eval

2017-03-30 Thread 'Burt' via Clojure
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 '(.ge