Skip to content

Instantly share code, notes, and snippets.

@bhb
bhb / gist:d82fcf0f80f555c28afa8db320be16c8
Created July 6, 2018 15:34
`set!` vs `alter-var-root`
Clojure 1.9.0
user=> (def ^:dynamic *x* "foo")
#'user/*x*
user=> *x*
"foo"
user=> ;; binding changes value
user=> (binding [*x* "bar"] *x*)
"bar"
user=> ;; using set! within binding changes value
user=> (binding [*x* "bar"] (set! *x* "bar") *x*)