Closures And Lambdas
Lambdas create function values that can be passed to standard library helpers, stored in script values, or called later inside the same runtime. They are ordinary script closures, not host threads or async tasks.
Syntax
Section titled “Syntax”Lambda parameters are written between | delimiters. The body can be an expression or a block, and parameters may carry type hints.
fn add_one(values) { return values.iter() .map(|value: i64| value + 1) .collect_array()}Captures
Section titled “Captures”Closures capture script-visible values from their surrounding scope. Captured host values remain host references or path proxies; a closure does not turn host state into GC-owned script memory or expose Rust &mut T.
fn above(limit: i64, values) { return values.iter() .filter(|value| value > limit) .collect_array()}Callback Use
Section titled “Callback Use”The core standard-library callback sites are iterator adapters such as map, filter, any, all, and find. Lazy adapters are one-shot and consume their source when a terminal method such as collect_array() or count() runs.
Runtime Boundaries
Section titled “Runtime Boundaries”Closure execution is budgeted like other script calls. Async functions can suspend while awaiting calls, but closures do not become task handles or gain manual-resume semantics. Suspended frames keep their original code version during hot reload, and closures cannot move across unrelated Runtime instances.