Metaprogramming in Dotty
summary
Scala 3 replaces Scala 2 macros with a redesigned, portable system that uses the tasty file format and two user-facing mechanisms: quotes and splices for generating typed code fragments and inline/match-types for compile-time specialization. Examples: a staged power function that unfolds when exponent is constant, tuple concat/size computed as types, and constValue to lift literal types into terms. A low-level API, tasty reflect, exposes tree inspection/construction for deeper macros; parts already power library optimizations and IDE tooling, with quotes landing around 3.1 and reflect stabilizing later.
AI-written summary · about
chapters (13)
- 0:00Start
- 2:38Syntax
- 3:14Macros
- 4:48By Name and by Value
- 9:55Pattern Matching with a Match
- 11:52Class Hierarchy
- 14:24Type Matches
- 15:46Topple Obstruction
- 21:33Quotes and Splices
- 27:54White Box Macros
- 34:56Pattern Match on Different Internal Trees
- 39:18How Do You Raise Custom Compilation Errors from Inline Methods and Macro
- 44:54Rule of Thumbs as to When You Should Use Inline and When You Should Use Macros








