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
.
您可以使用load-file
重新加载文件。
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 .
使用emacs和slime时,您可以按ctrl-c ctrl-l
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.