;; def: a global var in the current namespace
(def pi-approx 3.14159)
(def ^:private secret 42) ; private var
(def ^{:doc "Max connections"} max-conns 10)
;; let: local bindings (immutable)
(let [x 10
y (* x 2)] ; later bindings can see earlier ones
(+ x y)) ; 30
;; defn: define a named function
(defn square
"Returns x squared." ; docstring
[x]
(* x x))
(square 5) ; 25
(defn- helper [] :private) ; private function
;; declare: forward declaration
(declare process)
(defn start [] (process))
(defn process [] :done)
;; defonce: don't redefine on reload (keeps state during REPL development)
(defonce app-state (atom {}))