Let's Build a Hygienic Macro Expander
summary
Explains a concrete hygene mechanism: represent identifiers as syntax objects pairing a symbol with a scope-sets and generate a fresh scope on macro expansion so binding is subset comparison. Walks through a working Pico expander in Racket (~250 lines), implements let-syntax, quote-syntax, apply-transformer using a flip-scope trick to detect introduced names, resolves bindings unambiguously, and compiles macro code to the host evaluator; the implementation runs the examples and generalizes to full Racket hygiene.
AI-written summary · about
chapters (22)
- 0:00Intro
- 2:23Example
- 10:05Binding Form
- 10:27Scopes
- 10:55Macros
- 15:15Syntax
- 17:05Scope Record
- 17:45Add Scope
- 19:22Bindings
- 21:08Resolve
- 22:45Resolve Examples
- 24:21Importing Bindings
- 24:36Expand
- 26:04Expand lambda
- 26:39Expand macro
- 28:00Environment lookup
- 28:32Expansion
- 29:44Expand Identifier
- 31:07Expand Identifier Application
- 32:44Apply Macro Transformer
- 34:49Function Calls
- 37:10Evaluate
related talks
17mMacros for Domain-Specific Languages
01h 03mModern Macros
39mRust metaprogramming - macro_rules! beyond basics
23mMacro-embedding Compiler Intermediate Languages in Racket
25mRewriting Macros on the Fly: A Modular Approach to Administrative Reduction During(…)
19mRhombus: A New Spin on Macros without All the Parentheses
06mCode Generation: The Lisp Way
20mPredictable macros for hindley milner
