/clojure-mutable-namespace-example

Showing how namespaces/vars are mutable in Clojure

Primary LanguageClojure

Small repo showing mutability of Vars/Namespaces

In Clojure it is a convention not to “change Vars” in production systems, but Clojure itself will not stop you from doing bad things. The reason for this “utility” is so that the repl can function well.

It is not really the Var itself that is mutated rather the Var root binding, or the actual namespace in which it is located.

For the record, the only official way to change a Var is through thread local binding, or the alter-var-root function.

This leiningen project is set up so that it is compiled ahead of time. So you can run the code by:

lein uberjar
java -jar clojure-mutable-namespace-example-1.0.0-SNAPSHOT-standalone.jar