This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 11/4/2026.
List
import std/liststd/list — JavaScript implementation facet.
list.kjs · 13 tors
std/list — JavaScript implementation facet. · 37 more lines
Phantom lifecycles
Derived from the phantom labels in the declarations below — state! issues an
obligation the compiler will chase, !state discharges it, a bare state holds it without moving it. Nothing here is hand-drawn.
List_i64 1 state list!~part new koru_std/list.new.kz
Koru Standard Library: the `new` part of list.kz. Joined via `~part new` in list.kz; merged into the list module at load.
// Koru Standard Library: the `new` part of list.kz.
// Joined via `~part new` in list.kz; merged into the list module at load.
~[comptime|transform] pub tor new {
expr: Expression,
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
reporter: std/compiler:*ErrorReporter,
allocator: std.mem.Allocator
} -> SiteResult// Concrete i64 constructor (runtime). `new(i64)` rewrites to this. Carries the
// <list!> ownership obligation.
~pub tor new-i64 {}
| list *List_i64<list!>
| err string~part push koru_std/list.push.kz
Koru Standard Library: the `push` part of list.kz. Joined via `~part push` in list.kz; merged into the list module at load. container's constructor mints alongside it (see the synthesis section). The unified overload-by-container dispatch is the post-milestone gap (660_026 red pin), not this rung's surface.
// Koru Standard Library: the `push` part of list.kz.
// Joined via `~part push` in list.kz; merged into the list module at load.
//
// container's constructor mints alongside it (see the synthesis section).
// The unified overload-by-container dispatch is the post-milestone gap
// (660_026 red pin), not this rung's surface.
~[comptime|transform] pub tor push {
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
allocator: std.mem.Allocator
} -> SiteResult~pub tor push-i64 { xs: *List_i64<list>, v: i64 }~part len koru_std/list.len.kz
Koru Standard Library: the `len` part of list.kz. Joined via `~part len` in list.kz; merged into the list module at load. Current length as a scalar. (The `xs.len` expression form rides a separate bridge; this tor is the plain call form.)
// Koru Standard Library: the `len` part of list.kz.
// Joined via `~part len` in list.kz; merged into the list module at load.
//
// Current length as a scalar. (The `xs.len` expression form rides a separate
// bridge; this tor is the plain call form.)
~[comptime|transform] pub tor len {
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
allocator: std.mem.Allocator
} -> SiteResult~pub tor len-i64 { xs: *List_i64<list> } -> usize~part get koru_std/list.get.kz
Koru Standard Library: the `get` part of list.kz. Joined via `~part get` in list.kz; merged into the list module at load. Random access by index. <list> borrow — read, list untouched. `out-of-bounds` when i is past the end.
// Koru Standard Library: the `get` part of list.kz.
// Joined via `~part get` in list.kz; merged into the list module at load.
//
// Random access by index. <list> borrow — read, list untouched. `out-of-bounds`
// when i is past the end.
~[comptime|transform] pub tor get {
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
allocator: std.mem.Allocator
} -> SiteResult~pub tor get-i64 { xs: *List_i64<list>, i: usize }
| item i64
| out-of-bounds~part pop koru_std/list.pop.kz
Koru Standard Library: the `pop` part of list.kz. Joined via `~part pop` in list.kz; merged into the list module at load. binding keeps <list!>), so it can be popped again or freed. `empty` when there is nothing to pop. For scalar elements the popped value carries no obligation.
// Koru Standard Library: the `pop` part of list.kz.
// Joined via `~part pop` in list.kz; merged into the list module at load.
//
// binding keeps <list!>), so it can be popped again or freed. `empty` when there
// is nothing to pop. For scalar elements the popped value carries no obligation.
~[comptime|transform] pub tor pop {
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
allocator: std.mem.Allocator
} -> SiteResult~pub tor pop-i64 { xs: *List_i64<list> }
| item i64
| empty~part protos koru_std/list.protos.kz
Koru Standard Library: proto-resolution machinery for the list module — joined via `~part protos` in list.kz; members land in koru_list. Reads proto declaration flows (live and erased-marker) out of the program AST and flattens their field sets — `<:` parents merge ahead of the block (proto.resolve.kz owns the declaration-side gate). Bare entry name a proto-qualified element expression names, or null for a primitive. `i64` -> null; `Engine` -> "Engine"; `app/car:Engine` -> "Engine".
~part synth koru_std/list.synth.kz
Koru Standard Library: the `synth` part of list.kz. Joined via `~part synth` in list.kz; merged into the list module at load. Container synthesis for proto elements: synthesizeContainer mints the element record + List_<Name> handle struct + the six op tors (new/push/len/get/pop/free) into the CALLER's module. For a `ref(T)` field it enforces the home contract at the push boundary through the store module's shared enumeration (RefHomeQuery.homesOf) — the rule lives once, in the library that understands what mints handles. The name a proto door's first argument DECLARES. `<:` extension rides the labeled-arg split — `std/proto(Dog <: Animal)` arrives as (name: "Dog <", value: "Animal") — so the entry is the label minus '<', not the value. A plain value is a plain name. A synthesized tor decl + its `|zig` proc, appended as two Items.
~part fieldkit koru_std/list.fieldkit.kz
Koru Standard Library: the `fieldkit` part of list.kz — the small field/branch constructors the container synthesizers share. Joined via `~part fieldkit` in list.kz; merged into the list module at load. `ref(X)` inner name — the same spelling StoreRefs.inner parses in the store module; kept local because detection must run even when no std/store import exists — the no-home refusal is this consumer's job.
~part free koru_std/list.free.kz
Koru Standard Library: the `free` part of list.kz. Joined via `~part free` in list.kz; merged into the list module at load.
// Koru Standard Library: the `free` part of list.kz.
// Joined via `~part free` in list.kz; merged into the list module at load.
~[comptime|transform] pub tor free {
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
allocator: std.mem.Allocator
} -> SiteResult~pub tor free-i64 { xs: *List_i64<!list> }~part explain koru_std/list.explain.kz
Koru Standard Library: the `explain` part of list — joined via `~part explain` in list.kz; members land in koru_list. The consumer's explainer — the enforcement half of the facet story. std/refine reports what was DECLARED on a type; this reports what std/list ENFORCES at its boundary: for every `std/list:new(X)` site, the element's met facet is asked from refine's own fold (`metFields`) — the same producer the transform reads, so the report cannot drift from what push actually guards — plus the branch contract the push signature declares (`| ?ok` / `| ?!violated` / `| ?!oom`). One distinct element type and how many `new` sites construct it.
// @retain: explain_list_event is referenced from generated code
// (koruc's koru_explain_gather invokes every discovered [explainer]).
~[comptime|explainer] pub tor explain-list {
program: std/compiler:*const Program,
allocator: std.mem.Allocator
} -> ExplainReport