Skip to content

Instantly share code, notes, and snippets.

@gfredericks
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfredericks/9175913 to your computer and use it in GitHub Desktop.
Save gfredericks/9175913 to your computer and use it in GitHub Desktop.
pitfalls of changing a var to be dynamic
user> (def x 1)
#'user/x
user> (defn get-x [] x)
#'user/get-x
user> (binding [x 2] (get-x))
IllegalStateException Can't dynamically bind non-dynamic var: user/x clojure.lang.Var.pushThreadBindings (Var.java:320)
user> (.setDynamic #'x)
#'user/x
user> (binding [x 2] (get-x))
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment