There are two macros binding and with-bindings to redefine dynamic vars. However both seem to have the utility, what is the difference between them ?
;; binding
(def :^dynamic a 10)
(binding [a 20] a) ;; => 20
a ;; => 10
;; with-bindings
(with-bindings {#'a 20}
a) ;; => 20
a ;; => 10
both of them are changing the per thread dynamic scope, and resetting it to the root binding after the lexical scope is over.
with-bindingsis, as far as I can tell, primarily useful as a helper to pass bindings from another context by using a map returned by get-thread-bindings. The similar functionbindingwould be more typical when not importing bindings." - jas