Skip to main content

Module interp

Module interp 

Source
Expand description

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

Polydat’s one name-resolution surface (expression_engine.md §3.2). It lives in the kernel module because the operation is a general kernel facility, not a comprehension concern: the comprehension runtime uses it, synthesisers use it, and the executor uses it, and none of them depends on the comprehension AST’s shape.

§Functions

  • interpolate_via_kernel — looks up {name} placeholders against the kernel’s chain-aware bindings via PolydatKernel::lookup.
  • interpolate_with_lookup — the generic engine; the lookup closure decides where each leaf’s value comes from. Used by callers that compose their own lookup over the kernel plus workload params plus synthesis-time probes.
  • interpolate_operands — for an expression: a placeholder that is a whole operand reads its value with its type, and every other placeholder substitutes text.
  • whole_placeholder — whether a text is one placeholder and nothing else.
  • collect_string_interp_refs — extracts the placeholder names from a text without doing substitution.

§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§

KernelLookup
A kernel of any engine, as a scope names resolve in.
Layered
Bindings in front of another lookup: a tuple’s elements over the scope they were drawn in.
NoScope
The empty scope: no name resolves in it, and what has to compile under it is charged to the ledger it holds. A context-free source, one whose expression references no name, evaluates in this scope (comprehension_forms.md §10.7.0), at compile time or wherever no kernel is at hand.

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 (engines.md §3.6).

Functions§

collect_string_interp_refs
Extract every leaf {name} placeholder mentioned inside string-literal contexts in src into refs.
interpolate_operands
Interpolate an expression’s placeholders, reading each placeholder that is a whole operand as the value its name is bound to (comprehension_forms.md §3.1.5).
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.
whole_placeholder
The body of text when it is one placeholder and nothing else: {name} gives name, and {a_{b}} gives a_{b}. None for text with anything beside the placeholder (x_{name}, {a}{b}), for an escaped brace, and for an empty body.