Skip to main content

evaluate_spec

Function evaluate_spec 

Source
pub fn evaluate_spec(
    spec_text: &str,
    kernel: &dyn Lookup,
) -> Result<Vec<Value>, EmbeddingError>
Expand description

Evaluate a comprehension clause’s spec text against a Lookup scope.

Steps:

  1. interpolate_via_kernel resolves {name} placeholders against the kernel’s in-scope name space (own outputs + inherited extern values).
  2. Try dsl::compile::eval_const_expr_for(…, kernel.ledger()) on the result. On success with a Str value, re-parse as a comma-separated list with per-element type detection. Other typed variants become a single-element typed list.
  3. On eval failure (most common case for literal lists like "1, 10" which aren’t valid Polydat const expressions), fall back to parse_list_with_types on the interpolated text — 1U64, 1.5F64, trueBool, anything else → Str.

Errors propagate from interpolation (unresolved placeholder, runaway round count, etc.) — those are the user-facing actionable diagnostics.