Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If I load a file with (ns my-namespace) in it, why doesn't it switch my current namepace?

Tags:

clojure

I have a file like this

(ns boston.core)

If I (load "boston/core") from the REPL, however, my *ns* doesn't change to boston but remains user. Why is this?

like image 700
dan Avatar asked Feb 16 '11 23:02

dan


1 Answers

This is because load just loads the specified file (into the boston.core namespace, as specified at the top of the file). It doesn't do anything to the current namespace in the REPL.

If you also want to switch namespace in the REPL to use whatever has just been loaded you need to do something like:

(load "boston/core")
(ns boston.core)

Note that "boston/core" has a slash because it refers to a file resource, whereas namespaces themselves use a dot as separators.

like image 183
mikera Avatar answered Nov 18 '22 14:11

mikera