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

有些话、适合烂在心里 提交于 2019-12-23 10:01:25

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/5023349/if-i-load-a-file-with-ns-my-namespace-in-it-why-doesnt-it-switch-my-current

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!