✓
Passing This code compiles and runs correctly.
Code
// Capture-as-events: BUILT 2026-06-11 (was the frontier pin for the
// dissolution; green since the [transform]proc migration). The primitives:
// - `capture { ... }` and `captured { ... }` are the SAME shape — events
// taking one SOURCE BLOCK (bare braces, no parens; ratified 2026-06-11 —
// `name { ... }` is unambiguously an invocation since `=>` took over
// branch construction, 210_047). `capture { X }` seeds, `captured { X }`
// updates, and `captured { ... }` is just an event call, so it composes
// anywhere in a chain.
// - `! as acc` binds the accumulator as an EFFECT cell — live/during the loop
// (effects fire during; the cell is mutated each iteration).
// - `| captured result` is the CONTINUATION — the after-value, handed off once.
// It is OPTIONAL (`| ?captured`): if the work happened via side effects in
// the effect-branch, you may decline the final reading (cf. `~for`'s `| ?done`).
// - The `{ sum: ..., count: ... }` block is OPAQUE — the `captured` handler
// interprets it via the projector and emits per-target writes into the cell.
//
// Behavior when built: sum/count over 1, 3, 6, 8, 10; values > 5 are 6, 8, 10
// (sum = 24, count = 3, avg = 8).
~import std/io
~import std/control
~capture { sum: @as(i64, 0), count: @as(i32, 0) }
! as acc |> for(&[_]i32{1, 3, 6, 8, 10})
! each item |> if(item > 5)
| then |> captured { sum: acc.sum + @as(i64, item), count: acc.count + 1 }
| else |> captured { acc.sum, acc.count }
| captured result |> std/io:print.ln("{{ @divTrunc(result.sum, @as(i64, result.count)):d }}")
Actual
8
Expected output
8
Test Configuration
MUST_RUN