Skip to main content

evaluate_expr

Function evaluate_expr 

Source
pub fn evaluate_expr(expr: &Expr, ctx: &mut EvalCtx<'_>) -> Value
Expand description

Walk an expression tree and produce a Value.

Variables are resolved from ctx.ctx; functions are dispatched through ctx.registry. Eager functions receive pre-evaluated arguments; lazy functions (e.g. IF) receive raw Expr nodes and control their own evaluation order.

This is the single per-node entry point: every node that is reduced to a Value flows through exactly one evaluate_expr call (recursion re-enters here), so the opt-in EvalHook fires once per such node in post-order (children before parents), carrying the node’s own Span — see EvalHook for why the span is needed and how a consumer uses it to reconstruct a tree from the flat stream. Nodes that are structurally destructured rather than evaluated — e.g. the LAMBDA(...) callee of an Apply, which [eval_apply] pattern-matches without evaluating — never produce a value and so never fire as a node in their own right; each LAMBDA parameter is the one exception (see [eval_apply], and — for the six higher-order functions (MAP/REDUCE/BYROW/BYCOL/SCAN/MAKEARRAY) that bind lambda parameters through their own apply_lambda helper rather than eval_applycrate::eval::functions::array::apply_lambda, which fires the same per-parameter event once per invocation). When EvalCtx::hook is None the observation costs a single branch and nothing else; the real tree-walk lives in [eval_node].