Difference between using “def” to update a var and “alter-var-root”
问题 What's the difference between using "def" to update a var and using "alter-var-root"? e.g. (def x 3) (def x (inc x)) vs (def x 3) (alter-var-root #'x inc) 回答1: I find alter-var-root very rarely comes up in idiomatic Clojure code; not that there is anything wrong with it, it's just intended for corner cases. If you find yourself using it to build loops and such it's a sign something needs a different approach. I mostly see it in initialization routines for setting access credentials or loggers