Gomacro: code generation made easy and fun
summary
Interactive REPL Gomacro REPL produces and manipulates actual ast.Node trees with four lightweight operators so expressions like x + y return an ast.BinaryExpr ready for inspection. It combines quasiquoting with macros to splice evaluated nodes into generated ASTs, feeds expansions back to the compiler, and is used to produce ~100,000 of 120,000 lines (≈80%) of a fast interpreter that replaced a 6,000-line handwritten prototype; it runs and compiles on Linux/macOS.
AI-written summary · about
chapters (11)
- 0:00Introduction and motivation
- 1:12What is code generation
- 5:51Challenges with AST manipulation
- 8:20Introducing Gomacro
- 11:56What is Gomacro
- 15:48Quoting and quasi-quoting
- 21:11Runtime AST manipulation
- 23:35Macros in Gomacro
- 27:52Practical use cases
- 30:24Real-world example
- 33:36Conclusion and Q&A
related talks
42mEternal Sunshine of the Spotless Macro
44mJavaScript AST programming: Introduction and beyond
42mAvoiding macros with inline and derived
42mThe Macronomicon
38mDemystifying compilers by writing your own
01h 03mModern Macros
29mAutomatically Generated Supernodes for AST Interpreters Improve Virtual-machine P...
27mDo You Even Macro?
