Interface

The compiler generator itself is called cogen. If the interpreter is called like this:

Then you could compile program and compute the same ans like this:

The binding time pattern specifies which arguments to the interpreter are the program (static) and which are the data (dynamic). Note that generated compilers take their continuation as their first argument (this should probably change). An additional continuation is introduced because the compiler has to return somewhere.

Cogen's interp argument is a code structure [note coding]. cogen slightly extends the semantics of the root language to include the semantics of hints, lifting, and a number of primops.

The primops are convered in section bta except apply, which is used to create interpreters with an open-ended set of primops.

It also accepts lift directives (syntactically they appear like instructions). Lifting is required to avoid excessive specialization and non-termination. Obviously required lifts are handled automatically, but manual annotation is still often required when writing programs directly in root.

[example simple lift directive, mention complex lifting]