Take the 2-minute tour ×

(load-string s) according to its document:

"Sequentially read and evaluate the set of forms contained in the string"

Why it does not work in the following code?

(let [fun #(+ 1 2)]
     (load-string "(fun)"))

Thank you for your help!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You cannot access the lexical environment at all from load-string, so even this won't work:

(let [fun 12]
     (load-string "(+ 1 fun)"))

Only bound values work, see here:

Dynamic code with clojure

share|improve this answer
add comment

Your Answer


