Okay, here is the practical problem I am trying to solve, which is related to my previous post:
I am trying to create an application with a custom REPL environment and I am having problem getting the custom eval function to work properly.
Here is a contrived example that illustrates the problem as minimally as I could write it:
(ns test.core (:gen-class)) (def print-hello? false) (defn print-hello  "hello!!!") (defn test-read  (if (true? print-hello?) '(print-hello) (read))) (defn test-eval  (eval (test-read))) (defn test-print  (println (test-eval))) (defn test-loop  (loop  (test-print) (recur))) (defn test-exception [e] (println (.getMessage e))) (defn -main  (try (test-loop) (catch Exception e (test-exception e))))
If I run this program as is, I get a REPL environment as expected.
If I change the fourth line to
(def print-hello? true)
I expect to get an infinite looping of the string “hello!!!”.
Instead, I get:
java.lang.RuntimeException: Unable to resolve symbol: print-hello in this context, compiling:(NO_SOURCE_PATH:13:8)
I suspect this is a namespace issue. I expect
'(print-hello) to be interpreted in the
test.core namespace but I think, based on the responses to my previous posting, that it is being interpreted in some namespace other than
Or maybe my approach to creating a Clojure REPL application is completely wrong.
Any help appreciated.