Restaging Domain-Specific Languages: A Flexible Design Pattern for Rapid Development of(…)
summary
Proposes a concrete design pattern that replaces repetitive traversal code with a type class with children and rebuild interface so each AST node exposes its child list and a reconstruction function, then uses Scala 3 type class derivation and macros to generate those instances automatically. Reports that macro generation yields negligible compilation overhead compared to handwritten instances (reflection is slow), composes with visitor and strategic-rewrite styles, and is already used successfully in several DSL compilers (AD, data‑science hybrid, probabilistic) since 2019.
AI-written summary · about
chapters (13)
- 0:00Restaging DSLs introduction
- 1:24Compiler optimization challenges
- 3:11Defining domain-specific languages in Scala
- 5:44Transformations with boilerplate
- 7:11Rewrite strategies
- 9:39Restage design pattern
- 11:28Bottom-up and top-down transformers
- 13:58Boilerplate with type class derivation
- 16:49Productivity gains in compilers
- 17:54Performance impact evaluation
- 19:17Compatibility with visitor frameworks
- 20:03Restage pattern applications
- 21:05Summary and future directions
related talks
43mAdventures in Metaprogramming: Macros versus Shapeless
17mMacros for Domain-Specific Languages
42mAvoiding macros with inline and derived
28mVirtual Domain Specific Languages via Embedded Projectional Editing
12mMulti-Stage Programming with Generative and Analytical Macros
35mDesigning Domain-Specific Languages: A Comparison of Three Approaches by Example
48mMetaprogramming in Dotty
44mFunctional Interpreters and You
