This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 10/5/2026.

Control.capture

~import std/control.capture

Koru Standard Library: the `capture` part of control.kz.

control.capture.kz · 1 tors

Koru Standard Library: the `capture` part of control.kz. · 31 more lines
Koru Standard Library: the `capture` part of control.kz. Joined via `~part capture` in control.kz; merged into the control module at load. CAPTURE - Accumulation with pure semantics (ZERO OVERHEAD) Syntax: capture { total: 0 } ! as acc |> for(items) ! each i |> captured { total: acc.total + i } | captured final |> result(sum: final.total) Both `capture` and `captured` take a SOURCE BLOCK — bare braces, no parens. Bare `name { ... }` is unambiguously an invocation since the `=>` construct glyph took over branch construction (210_047). The parens forms `capture({...})` / `captured({...})` are retired (ratified 2026-06-11). A block holding a single bare expression (`capture { entity }`) seeds from an existing value instead of building a new struct cell. ARCHITECTURE: - capture is a comptime transform: `! as` binds the cell (live/during), `captured { ... }` invocations are rewritten into general `.assignment` nodes, `| captured` is the one-shot after-read. SEMANTICS: - Pure from Koru's perspective (captured computes the NEXT value) - Efficient mutation in generated Zig (var cell + field writes) - Decomposes fold while preserving purity guarantees The tor declares the USER surface (second [transform]proc migrant after std/regex:match): a source block, the `! as` cell effect, the optional `| captured` after-read. The shape checker enforces this contract with zero capture-specific code. The machine interface (invocation/item/program/ allocator → transformed SiteResult) is the proc-return convention.

capture

keywordcomptimetransform koru_std/control.capture.kz:34