📝Clojure: dynamic scoping

tags

Dynamic scoping

(def ^:dynamic name "world")

;; or
;; (declare ^:dynamic name)

(defn hello []
  (printf "Hello, %s!\n" name))

(binding [name "blah"]
  (hello))

(hello)
Hello, blah!
Hello, world!

Backlinks