Symbols and Bindings

Symbols

Clojure symbols are references to values. (default namespace is user)

(def foo "bar")
;; -> #'user/foo

foo
;; -> "bar"

user/foo
;; -> "bar"

let introduces scope and preserves original value, and expects pair of symbols and values in vector form.

(def foo "bar") 
;; -> #'user/foo

(let [foo "barx"] foo)
   ;; -> "barx"

foo
;; -> "bar"
  • def to create global vars
  • let to create temporary bindings