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?
How do I remove a function from the lein repl?
Asked Answered
note: I am connecting to the lein repl through the vim-fireplace plugin, and running tests with the 'cpR' command. –
Pannikin
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)
That seems to do the trick. Is there a similar function to 'unmap' all functions? –
Pannikin
you can get a list of all the function with ns-map. then unmap them. –
Balanchine
© 2022 - 2024 — McMap. All rights reserved.