During a lein REPL session, I may define a number of functions. However, sometimes I would want the session to 'forget' them - for example when I execute (run-all-tests), this highlights failures from tests that I no longer need. Is there a way to remove functions from the session, or to clean it, without restarting?
Asked
Active
Viewed 797 times
5
-
note: I am connecting to the lein repl through the vim-fireplace plugin, and running tests with the 'cpR' command. – Rich Ashworth Mar 25 '13 at 23:33
1 Answers
7
use ns-unmap
as described on the Clojure namespaces page http://clojure.org/namespacesuser>
(defn foo [x] (inc x))
#'user/foo
user> (foo 3)
4
user> (ns-unmap *ns* 'foo)
nil
user> (foo 3)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:1:1)

Arthur Ulfeldt
- 90,827
- 27
- 201
- 284
-
That seems to do the trick. Is there a similar function to 'unmap' all functions? – Rich Ashworth Mar 26 '13 at 16:44
-
2you can get a list of all the function with ns-map. then unmap them. – Arthur Ulfeldt Mar 26 '13 at 18:09