Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.75 KB

HACKING.rst

File metadata and controls

42 lines (30 loc) · 1.75 KB

Overall Design

The macro expander itself is a set-of-scopes expander, based on Matthew Flatt's paper from POPL 2016 and described quite accessibly in his talk from Strange Loop.

Additionally, there is a module system patterned after Racket's.

This macro expander has a few differences:

  • Rather than performing a depth-first traversal of the input syntax, expanding as it goes, our expander maintains a queue of expansion tasks. Tasks indicate the expression to be expanded as well as its resulting location in the final output. Dependency information is tracked in order to constrain the scheduling of expansion tasks.
  • The core language does not coincide with the input language. Having an independent core language will hopefully allow us to overcome the overhead associated with recursive uses of local-expand, as well as enabling a second, trusted type checking pass.
  • Type checking and macro expansion are interleaved. Every expansion step in an expression or pattern context knows what type the resulting program will have.

The type checker is a mostly-vanilla Hindley-Milner, based on Sestoft's description in Programming Language Concepts, extended with user-definable datatypes and Racket-style phase stratification of bindings. It uses Rémy's optimization of generalization, where type metavariables are assigned levels to avoid scanning the context at generalization time.