Expand description
Compile-time support for the for construct (for_traversal.md §4):
element typing, body-to-child-program lowering, and the metadata a
parent program carries for each traversal and producer.
A for body compiles once, at parent compile time, into the
interpreter’s child PolydatProgram keyed by the statement’s
lexical position, and once per other engine, at the first
activation on that engine (for_traversal.md §5.1). Its element names
become IterationExtern inputs typed from the comprehension’s
sources; outer wires it references become cascade externs typed from
the parent’s manifest. Activation otherwise only allocates state
over that program.
Structs§
- Body
Source - A traversal body as its parent compiled it: the child file and the compiler settings the parent used, so the same body compiles on any engine, once, keyed by the engine as the interpreter’s program is keyed by the body’s position (for_traversal.md §5.1).
- Producer
- A producer binding,
name := for ..., recorded on the program that declares it so traversals overnameresolve at compile time. - Traversal
- A compiled traversal: one
forstatement and the child program its body lowered to.
Functions§
- child_
file - Build the child file for a traversal body: an implicit
cycleinput, one extern per element, one cascade extern per outer wire the body references and the parent exposes, then the body itself. Returns the file and the cascade list. - element_
types - Type each element name of a comprehension from its source, per
for_traversal.md §3.3.
probetypes a generator call expression the way the enclosing compiler would. - resolve_
source - Resolve a traversal’s source to a comprehension: inline text as is, a producer reference to the producer bound in the same scope, and a derivation to the base producer with its filter and order applied.
- resolve_
source_ with resolve_sourceunder a validation mode (comprehension_forms.md §5.8): a strict compile refuses a degenerate composition, a permissive one returns it as a warning for the compile event log.- strip_
for_ forms - Split a parsed file into the statements the parent compiles directly,
the
forstatements to lower into child programs, and the producer bindings to record. Order within each group is preserved.