See also ‣
Techniques
- Reflection: Several approaches (e.g. towers, Java-style, MOPs) which vary in support for: introspection (read) vs. intercession (write), structural (classes, methods, fields) vs. behavioural (assignment, creation, invocation)
- Reflective tower: Run-time structure and behaviour changes (”full reflection”) of language system, very powerful but difficult to optimise
- Syntactic macros: Compile-time host language procedure or pattern that transforms input program
- Multi-stage programming: Code generation and execution, with potentially several stages chained together, typically run-time (but not always), some amount of static type safety
Time
- Compile-time: macros (Lisp, Scala, etc.), multi-stage programming (Template Haskell, Metalua, Converge, Mython, Delta)
- Run-time: reflection (Black etc.), multi-stage programming (MetaML, MetaOCaml, Metaphor, Mint, LMS, Terra)
Space
- [ ] Read time and space paper
Implementations
- Scala LMS: Run-time code generation technique, applied to many research problems
- Scala 3 / Dotty: Both compile-time macros and run-time code generation
- Terra: Run-time code generation of static Terra code via dynamic Lua
- [ ] Add more to highlight others of interest
Use cases
- Languages become malleable: users can provide language-level features themselves
- Modifying / overloading language semantics
- Code reuse that goes beyond typical language abstractions (functions etc.)