Schooner.Compiled (schooner v1.0.0)

Copy Markdown View Source

Opaque artifact produced by Schooner.compile/2 and consumed by Schooner.run_compiled/2.

A %Compiled{} holds the post-expansion core AST of a program together with the runtime variable bindings that the program's (import ...) declarations resolved to at compile time. Macros are already gone from the AST — let, cond, when, case, etc. have been rewritten into quote / if / lambda / define / define-values / begin / letrec* / quasiquote / application / variable references.

Reuse semantics

The same %Compiled{} can be passed to Schooner.run_compiled/2 many times against many Schooner.Environments — that is the embedding cache win. The captured var_bindings are re-applied to the runtime env on every call; macros expanded at compile time stay expanded.

Compatibility constraint: a compiled program is valid against any environment whose macro environment is compatible with the registry passed to compile. Variable sets can differ freely — host primitives can be swapped, and the compiled program's (import ...) bindings are baked in so they shadow any same-named runtime overrides. Macro additions made after compile (via a different Environment at run time) will not re-expand the program.

Opacity

Embedders must treat the struct as opaque — pattern-matching on internals is unsupported and reserved for evaluator changes (the v2.0 evaluator rewrite is the seam this opacity protects).

Summary

Types

t()

@opaque t()