Last active
August 29, 2015 13:56
-
-
Save gfredericks/9175913 to your computer and use it in GitHub Desktop.
pitfalls of changing a var to be dynamic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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