Skip to main content

Module eval

Module eval 

Source
Expand description

Comprehension spec evaluation — text → typed value list.

§What this module does

A comprehension clause var in expr ships its expr as free-form workload-author text. At runtime, the executor needs to turn that text into a list of typed values to enumerate over. That’s what evaluate_spec does, given a Polydat Kernel that holds the in-scope name space (own outputs + inherited externs from materialize_wiring_from_outer).

§Pipeline

  spec_text
      │
      ▼
  interpolate_via_kernel  ← {name} → kernel.lookup(name)
      │
      ▼
  eval_const_expr_for     ← optional: Polydat expression eval,
                             charged to scope.ledger()
      │
      ▼
  parse_list_with_types   ← comma-split, per-element type
      │
      ▼
  Vec<Value>              ← what the executor enumerates

§Where this used to live

Pre-Phase-C this code lived in the host. The lift was driven by the principle that Polydat is the canonical owner of what a comprehension means, including how its spec strings resolve (see crates/polydat/docs/design/comprehension_forms.md). The host now consumes this API rather than implementing it.

Functions§

enumerate_tuples
Enumerate the typed tuples a Cartesian comprehension produces.
evaluate_spec
Evaluate a comprehension clause’s spec text against a Lookup scope.
parse_list_with_types
Parse a comma-separated text list, detecting each element’s native type. SRD-18b’s “native types as the general rule”: "1, 10"[U64(1), U64(10)], "1.5, 2.5"[F64(...)], mixed → each element gets its own native type.
pre_evaluate_clause
Pre-evaluate a clause’s spec text at synthesis time, using probes for prior clauses’ first values and workload_params as a fallback source for names not yet promoted to workload- kernel const bindings.
value_to_polydat_type_name
Map a Value to the canonical polydat extern type keyword.