philipbohun.com

Glojure by Example: Bindings

def names a var. let names locals for the body that follows. Both kinds of binding are immutable: there is no assignment to a local, and there is no separate const form. Later examples use atoms when a value has to change.

(def answer 42)
(println answer)

(let [x 1
      y 2]
  (println (+ x y)))

An inner let can shadow an outer name. The outer binding is unchanged.

(let [x 1]
  (let [x 2]
    (println "inner" x))
  (println "outer" x))

Bindings print the values they hold.

$ glj bindings.glj
42
3
inner 2
outer 1

Next example: Keywords and Symbols.