If you’re a Clojure programmer, it’s likely that you don’t write many macros. Everybody is always warning against writing too many macros. Those people are wrong: macros are great and you should write more of them.
Here are some good uses for macros:
- Control structures keep your code simple.
with-macros keep your resource usage tidy.
def macros, because I often need the corresponding non-def function macros and I usually have to read the source to figure out how they differ. That said, they’re okay when they look like this:
(declare foo) (defmacro deffoo [x & args] `(def ~x (foo ~@args)))
You could even write a macro for defining