*earmuffs*

conventionsince v0.0-927 in clojureEdit

A naming convention for dynamic vars (unenforced).

  • (def ^:dynamic *foo* 1)

Details:

Dynamic vars are global vars that you intend to temporarily rebind with binding.

NOTE: Sometimes, the core library uses the earmuffs convention for non-dynamic special global vars (e.g. *clojurescript-version*, *main-cli-fn*).


Examples:

(def ^:dynamic *foo* 1)

(defn print-foo []
  (println *foo*))

(print-foo)
;; 1

(binding [*foo* 2]
  (print-foo))
;; 2

(print-foo)
;; 1

See Also: