murtaza52
murtaza52

Reputation: 47431

reloading a ns in repl

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

Upvotes: 2

Views: 622

Answers (4)

Arthur Ulfeldt
Arthur Ulfeldt

Reputation: 91554

when using emacs and slime you can hit ctrl-c ctrl-l to reload the currend namespace and reload anything it includes.

Upvotes: 2

kotarak
kotarak

Reputation: 17299

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.

Upvotes: 6

Ankur
Ankur

Reputation: 33637

You can use load-file to reload the file.

Upvotes: 3

Paweł Łoziński
Paweł Łoziński

Reputation: 1094

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.

Upvotes: 2

Related Questions