6 ms·
Pardon, I don't know Clojure inside and out: are namespace significantly better than packages for the purpose of macro hygiene?
by ToastOpt 15y ago
Pardon, I don't know Clojure inside and out: are namespace significantly better than packages for the purpose of macro hygiene?
- chousuke 15y agonamespaces in combination with how syntax-quote (`) autoqualifies symbols and let disallowing qualified identifiers makes it noticeably more difficult to introduce a name clash. for example the following macro results in an error when you try to run the expanded code: (defmacro ex [x] `(let [y 1] (~x y))) because it expands to (let [namespace/y 1] ...) which is disallowed. When you need to, there is a way to force an unqualified symbol by explicitly quoting and unquoting a symbol, and ` provides autogensyms, so it is very convenient to use. Namespace-qualifying also means that post-expansion changes to your local namespace won't change the meaning of symbols that referred to things in an external namespace when the macro was expanded.