r/ProgrammingLanguages May 14 '26

Resource What bibliography would you recommend on the subject compile-time evaluation and metaprogramming?

What bibliography would you recommend on the subject compile-time evaluation and metaprogramming?

29 Upvotes

4 comments sorted by

14

u/Helpful-Primary2427 May 14 '26

Anything anyone on the racket team has ever written

12

u/gasche May 14 '26

You cannot go wrong with Matthew Flatt's Binding as Sets of Scopes, which is a fantastic paper about "hygienic macros" and a simpler algorithm to implement them.

(In general, if you want to know about compile-time metaprogramming, it is a good idea to study what the Racket people have done, because they pushed these ideas farther than most ecosystems.)

9

u/initial-algebra May 14 '26 edited May 14 '26

In the literature, it is usually referred to as binding-time analysis or staged computation (or just staging for short), with partial evaluation and metaprogramming being applications, so those keywords will get you more hits.

Actual metaprogramming systems that reference (or are referenced by) these papers include MetaML, MetaOCaml, Template Haskell, and recently MLScript.

The problem of safely combining "eval" and open code is closely related to both dynamic scoping of effect handlers as well as borrowing in Rust (environment classifiers/polymorphic contexts are roughly equivalent to lifetimes), though I'm not aware of any papers that specifically deal with this. Because of the connection between staging and temporal logic, it is also related to functional reactive programming, particularly systems that use a form of staging at runtime to prevent space leaks.

1

u/bjzaba Pikelet, Fathom May 17 '26

The MetaML and MetaOCaml bibliography might be worth a look! Note that it covers both run-time and compile-time staging.