A few tips for writing macros
summary
Nine concrete tips for safer Clojure macros: prefer functions unless controlled evaluation is required; show an example expansion next to the macro; name params with expr suffix so code shows it gets expressions not values; validate assumptions early with asserts or clojure.spec; use syntax-quote and auto-gensym (#) to avoid name collision; ensure each arg is evaluated once; debug with macroexpand-1 + pprint; build expansions via helper functions.
AI-written summary · about
chapters (9)
- 0:00Intro
- 0:39Dont use a macro
- 1:43Include an example expansion
- 2:16Append expressions
- 2:42Capture assumptions
- 3:12Backtick operator
- 4:15Evaluate multiple times
- 4:52Macro Expand 1
- 5:48Conclusion
related talks
42mThe Macronomicon
39mRust metaprogramming - macro_rules! beyond basics
40mLet's Build a Hygienic Macro Expander
06mCode Generation: The Lisp Way
25mRewriting Macros on the Fly: A Modular Approach to Administrative Reduction During(…)
01h 03mModern Macros
27mDo You Even Macro?
30mAdventures in homoiconicity
