A Clojure symbol is a symbolic identifier used to name vars, local bindings, and function parameters. Unlike a string, it can carry metadata, include a namespace qualification, and participate in code as data. When a symbol appears in an expression, Clojure looks it up in the current namespace or surrounding scope. section 15.1
Symbols have several practical properties:
- Write a qualified symbol with a slash: a/b names b in namespace a. Use name and namespace to retrieve its two parts. section 15.1
- Read Clojure forms as data to obtain symbols rather than evaluated values; macro evaluation also relies on this distinction. section 15.1
- Attach metadata to symbols, although symbols are intended for program identifiers rather than general text. section 15.1
- Create symbols with symbol or its two-argument constructor, but consult reader rules because constructors can bypass validation performed by literal syntax. section 15.1
Qualification changes identity
(def ax (symbol "a/x")) (def bx (symbol "b/x")) [(name ax) (name bx)] ;; ["x" "x"] (= ax bx) ;; false [(namespace ax) (namespace bx)] ;; ["a" "b"] Both symbols have the same name, x, but their namespace qualifications make them unequal. section 15.1
(def form (read-string "(a b)")) ; #1 (map type form) ; #2 ;; (clojure.lang.Symbol clojure.lang.Symbol) (defmacro reading-symbols [& symbols] ; #3 `(map type '~symbols)) (reading-symbols a b) ; #4 ;; (clojure.lang.Symbol clojure.lang.Symbol)
Inspecting a read form and a macro-produced form shows that identifiers remain clojure.lang.Symbol values before evaluation. section 15.1




