I'm trying to embed a swank-clojure repl into my application for the purpose of connecting while the app is running to muck around with things. However, I'm having trouble figuring out how to access the enclosing environment after starting the repl.
Embedding the swank-clojure REPL is easy enough:
(ns mytest
(:use [swank.swank :exclude [-main]])
(:gen-class))
(defn -main [& args]
(let [x 123]
(swank.swank/start-repl)))
Run the program.. then over in emacs:
M-x slime-connect
That works fine and I am connected. Now, what I hoped was that this would work:
(println x)
;; 123 (what I was hoping for)
;; Unable to resolve symbol: x in this context (cruel reality)
So that doesn't work as a way to pass the current environment to the embedded REPL.
Is there any way for the embedded REPL to interact with my running program?
If not, what reasons are there to embed a REPL?
If it makes any difference, I am trying to run this as a JAR.
This thread seems related, but I wasn't able to get anywhere from it:
http://stackoverflow.com/questions/2661025/embedding-swank-clojure-in-java-program