- lexical scope (static scope): dependent only on the program text.
- dynamic scope: dependent on the runtime call stack.
(def x 1)
default Var isstatic
, usinglet
for local Var,with-redefs
to change the root binding var within its scope (visible in all threads).(def ^:dynamic x 1)
dynamic Var, usingbinding
to change value (thread-local, cannot be seen by any other thread).
In example bellow:
binding
only changes the value of*dynamic-var*
within the scope of the binding expression