Skip to main content

Module interp

Module interp 

Source
Expand description

{name}-style template interpolation against a Polydat Kernel.

Surface #5 home (per polydat/docs/design/comprehension_cutover_contact_surfaces.md). Previously lived in polydat::iteration::comprehension::eval; relocated to the kernel module because the operation is general GK-kernel facility, not a comprehension concern. The comprehension runtime uses it; synthesisers use it; the executor uses it; but it doesn’t depend on comprehension AST shape.

§Functions

§Semantics

Iterative leaf-placeholder substitution with escape handling and a round cap:

  • Leaf: {name} whose body contains no further {. The dynamic form {a_{b}_c} is resolved by first substituting {b}, then re-scanning for the resulting {a_<b-value>_c} as a leaf.
  • Escape: \{ and \} pass through as literal { / } and are removed from the final string.
  • Round cap: if substitution doesn’t stabilize in ROUND_HARD iterations, returns Err (the input had cyclic placeholders).
  • Unresolved name: any {name} that survives the substitution rounds errors with a diagnostic naming the missing binding.

Structs§

Layered
Bindings in front of another lookup: a tuple’s elements over the scope they were drawn in.

Traits§

Lookup
Name resolution for comprehension sources and predicates: what a {name} placeholder or a bare identifier reads. The interpreter kernel is one; a Layered view puts a tuple’s bindings in front of another, so opening a traversal needs no kernel of the engine that opens it (engine parity, step 8).

Functions§

collect_string_interp_refs
Extract every leaf {name} placeholder mentioned inside string-literal contexts in src into refs.
interpolate_via_kernel
Interpolate {name} placeholders against kernel.
interpolate_with_lookup
Iterative leaf-placeholder substitution with escape handling, round cap, and final unresolved-name check. The lookup closure decides where each leaf’s value comes from.