3

How can I get a clojure "def" to re-evaluate without using :reload?

2 Answers 2

5
(def x 0)
x   ; => 0
(def x 1)
x   ; => 1

You can't re-def a var from another namespace, so you should switch to it's namespace with in-ns before re-defing.

3
  • 1
    note: if your doing that you should be 100% sure that there is no better way.
    – nickik
    Dec 17, 2010 at 0:43
  • Does this mean you would would have to "eval" the def again?
    – yazz.com
    Dec 17, 2010 at 9:02
  • Yes. If you are on slime, you just change def in source code and evaluate it with C-x C-e.
    – koddo
    Dec 17, 2010 at 13:06
2

You can also call load or load-file at the repl.

(load-file "foo/bar.clj")
(load "foo/bar")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.