Lets say I have a code file that has the ns - (ns abc.a). Now I start my repl and am in the ns- (use-ns 'abc.a).
Now if I change any code in the file, how do I get to reload the ns in the repl?
Thanks, Murtaza
You can hot reload the code with (require :reload 'abc.a)
or (require :reload-all 'abc.a)
. The latter also reloads all the required namespaces of abc.a
while the former only reloads abc.a
.
When you set a namespace in REPL you don't load any code from the file where the namespace is defined. You need to execude all the code from the file (simplest way is copy-paste).
So if your file looks like this:
(ns abc.a)
(def x 3)
then after executing user=>(ns abc.a)
in REPL you get the prompt abc.a=>
. Your namespace is changed but there is nothing in it yet. Type x
to see it is not defined. It is only after executing abc.a=>(def x 3)
, that you get your code loaded to the ns in REPL.
If you then change your x
definition in file (say to (def x 5)
), just type the new one in REPL to get this code reloaded.
If you're using emacs, I'd advise you to read this question.
when using emacs and slime you can hit ctrl-c ctrl-l to reload the currend namespace and reload anything it includes.