开发者

Does :reload work globally in clojure?

Say I have two source files in a clojure program and I reload a changed external module using :reload in one of the modukes. Does the开发者_运维问答 reload only occur in scope of the module which calls reload or is the reload in effect for all modules?


If a clojure file is reloaded, then it is reloaded. This is not subject to a scope - it just loads and evaluates whatever is in the file.

What exactly happens then is dependent on what's in the file. For instance, reloading a (def) form overwrites the root binding for that var. Another interesting consequence is that deleting a var in a file and then reloading it will not remove the var.

Require and use also have side-effects beside loading, and a :reload does not mean all other require and use statements that refer to the same file are re-evaluated.


i'm guessing that, by using :reload, you update a namespace on your repl (on your current instance of the java runtime). therefor, my answer would be: it is global (because now your instance of the runtime has the new code)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜