A macro produces code that runs in its caller’s context. Macro hygiene helps prevent names introduced by that code from accidentally colliding with names around the macro call. Clojure’s syntax-quote provides two practical safeguards: namespace qualification and automatically generated symbols. section 4.1
Inside syntax-quote:
- An ordinary symbol is qualified, so `foo` becomes a symbol such as `user/foo` rather than an unqualified name. section 4.1
- A symbol ending in `#` receives a generated identifier. Use the same spelling for references to a binding introduced within one syntax-quoted expression. section 4.1
- `~'foo` deliberately inserts an unqualified `foo`. This bypasses the safeguards and is rarely appropriate. section 4.1
Give a macro’s local binding its own name
`(let [x# 1] x#)` produces a `let` whose binding and reference share a generated name, such as `x__37__auto__`. A retry macro similarly uses names such as `attempt#` and `warn#` for variables it introduces. section 4.1
`[foo foo# ~'foo] ;; [user/foo foo__45__auto__ foo]
Compare the three results in one expression: a qualified ordinary symbol, a generated symbol, and an intentionally unqualified symbol. section 4.1
Prefer qualification and `#`-suffixed names when constructing macro output. Use `macroexpand` to inspect the resulting code without executing it. section 4.1 section 4.0

