cli: add initialized buffers and safe owning vectors
Introduce linear_buffers through the specification, AIR parser/serializer, verifier, deterministic interpreter and source lowering. A buffer owns an initialized prefix with explicit reserve, bounded push, moving pop/views and recoverable empty-only free. Growth charges old+new capacity; failed growth, full push and nonempty free preserve or return complete ownership. Implement compiler-pinned safe std.vec with nine operations for Copy values, owners, files and channel endpoints. Permit complete Copy moves inside specialized generic bodies without weakening monomorphic or borrow rules. Update RFC 0024, Q-036, STD-6a/b, reference grammar, Quick Reference, bundles, source coverage and CI. Remaining collections stay STD-6c. Validation: unit tests and AIR round-trip; 757 conformance cases; 56 dedicated buffer cases with per-instruction collection and 32-seed schedule stress; extended memory test; hosted smoke; 36 module, 20 generic, 49 linear and 118 buffer CLI checks; 91/91 source constructs; Zig fmt and reference bundles. Full source bundle: 49,589 -> 52,384 cl100k tokens (+5.6%); AIR 175,736 bytes. The reference interpreter's push copies its initialized prefix; no native performance or empirical MCC benefit is claimed.
This commit is contained in:
101 files changed
+2377
-71
No files matched your search
@@ -457,3 +457,16 @@ Construction (`struct.make`, `enum.make`, `array.make`) MUST consume every linea
|
||||
Among heap/frame/region storage forms, only individual `own<T>` may hold linear aggregate content in this phase; channels and mutexes retain their existing complete-value transfer rules. `own.pack` explicitly moves a value into an individually owned allocation: on failure, the error continuation receives both alloc_error and the original complete value. `own.take` consumes the owner, frees the allocation and returns its complete content, including all nested owners/resources. `own.free` MUST reject E1001 when content is linear. Repeated heap arrays, region allocations and frame locals MUST remain Copy-only; bulk freeing cannot destroy resources. Dynamic linear buffers require a separate feature/API with an explicit drain contract. Existing heap/region operations on Copy values retain their semantics.
|
||||
|
||||
Verifier state is whole-value availability, existing borrow provenance and initialization, with no per-field moved state. Structural Send/Share still apply, so transfer to workers/channels/mutexes requires their ordinary rules. The deterministic interpreter moves existing handles, performs swaps as one instruction and uses existing allocation budgets/fuel; it performs no user cleanup on normal paths or traps. AIR format 0 remains compatible: previously unsupported feature/type/opcode cases gain meanings; previously accepted Copy modules keep identical behavior.
|
||||
|
||||
|
||||
## 26. Dynamic initialized buffers
|
||||
|
||||
Feature `linear_buffers` adds the linear complete value `buffer<T>`, accounted handle size 24 bytes. T MUST be a complete value with ordinary linear_aggregates member rules: no borrow/storage/function-bound content. Ownership type graphs through buffer wrappers MUST be acyclic (E1003). `buffer<T>` is Send exactly when T is Send and Share exactly when T is Share, like own_array. Local propagates through T; no guard/task/channel-transfer gate is weakened.
|
||||
|
||||
A buffer uniquely owns capacity C and a contiguous initialized prefix of length L, 0 ≤ L ≤ C. Only [0,L) is observable. Every live linear element is owned exactly once inside that prefix. There are no observable holes, default values, implicit destructors or partially moved fields. Constructors start with L=0. Push/pop change the prefix by one complete value; pop is LIFO. Views borrow precisely the prefix. Metadata changes, growth and consumption obey ordinary exclusive alias and task-loan rules; a live view excludes those operations, even when a dynamic branch would perform no change.
|
||||
|
||||
Allocation charges C × accounted_size(T), using checked arithmetic and the named mem.alloc authority. Overflows/authority exhaustion return alloc_error::budget_exceeded. Zero capacity is valid and charged zero. Capacity is a target usize, not a format-0 fixed-array type length. Growth to C' > C allocates explicitly from the supplied authority: it MUST charge the complete new capacity before releasing the old charge to its original authority. Thus peak live charges include both allocations. Success transfers all initialized values and changes capacity/authority; failure preserves length, capacity, contents and old authority exactly. A request ≤ C succeeds without mutation/allocation, but public effects/capability requirements remain explicit. Unused capacity contains no user value and cannot be borrowed.
|
||||
|
||||
Push requires no allocation effect or capability: if L<C, it transfers one value and increments L; otherwise it returns that original value without mutation. Pop returns the last complete value and decrements L, or reports empty with no change. `buffer.free` consumes the whole handle: it frees storage only when L=0, otherwise returns that same complete buffer. This applies uniformly to Copy and linear T. Every normal path MUST explicitly transfer/drain nested resources; a caller MAY trap under the existing abnormal-path contract but no cleanup is inserted. Existing own.array, own.free and region/frame rules retain their meanings.
|
||||
|
||||
The verifier tracks whole buffer ownership and existing borrow provenance, not a symbolic length or per-slot initialization state. Prefix validity is enforced by the trusted primitive semantics. Views use existing slice borrow/end, load/store bounds and explicit value.swap rules. Copy loads/copies require Copy T; ordinary overwrite of linear T remains forbidden. The deterministic interpreter preserves buffer identity and initialized prefix across tracing collection, tasks and swaps; metadata accesses participate in race checks, and allocation uses existing deterministic budgets and fuel. No synchronization, ambient authority, implicit allocation or new trap is added. The feature is additive in AIR format 0.
|
||||
@@ -556,7 +556,7 @@ Example: two workers square the two halves of one buffer in parallel; both loans
|
||||
| integers, `bool`, built-in enums | yes | yes |
|
||||
| `cap<K>` (every kind) | yes | yes — the authority object is shared and its host side is synchronized |
|
||||
| `file<…>`, `listener`, `stream` | yes | no |
|
||||
| `own<T>`, `own_array<T>` | if `T` is | if `T` is |
|
||||
| `own<T>`, `own_array<T>`, `buffer<T>` | if `T` is | if `T` is |
|
||||
| `region` | yes | no — allocation through a shared borrow mutates the region |
|
||||
| `ref<T>` | if `T` is `Share` | if `T` is `Share` |
|
||||
| `mut<T>` | if `T` is `Send` | no |
|
||||
@@ -857,4 +857,3 @@ Common properties:
|
||||
- *Exact coverage, normative litmus corpus only.* For every test of `reference/concurrency-litmus.md`, the outcomes observed under exhaustive exploration equal the oracle's allowed set: `observed_exhaustive = allowed` (§20.5).
|
||||
- *Weak reads.* A read whose ordering is not `seq_cst` may read any write the model allows. The choice is a draw from the schedule generator (§36.2) and counts in `schedule.choices`.
|
||||
- *No weak access.* A run with no non-`seq_cst` access makes no extra draw, and every read reads the latest write.
|
||||
|
||||
@@ -333,3 +333,22 @@ Operands MUST be mut<T> and T; T MUST be an initialized value, never a borrow/st
|
||||
### `own.pack T %value, %cap, ok -> @success, err -> @failure`
|
||||
|
||||
Operands MUST be complete T and cap<mem.alloc> (E1001/E3201); T may be Copy or linear. No SSA result; success receives own<T>, failure receives (alloc_error,T) (E5002/E1001). Linear input is consumed on both edges; success owns it inside the allocation, failure owns the same original value. Memory: new allocation initialized with the complete value on success; none on failure. Effects: mem.alloc. Capability: explicit bounded mem.alloc. Synchronization/traps: none; ordinary alloc_error failure reasons/budget rules apply. Interpreter transfers handles without duplicating ownership and charges/frees the same accounted bytes as own.new/own.take.
|
||||
|
||||
|
||||
## Dynamic buffers (`linear_buffers`)
|
||||
|
||||
These instructions add no concurrency effects. Metadata access uses existing shared/exclusive race and task-loan checks; views carry child provenance. Valid buffer states MUST NOT trap; allocation failure is an outcome, while execution limits retain spec 11 behavior.
|
||||
|
||||
All operations require linear_buffers and its full dependency closure (arrays, capabilities, effects, heap, linear_aggregates, ownership, resources). buffer<T> content and lifetime rules are spec 03 §26. T MUST be a complete value. Counts/indices are usize. All continuations receive exactly the listed parameters (E5002 count, E1001 types), with no SSA result for terminators. New operations add no traps, except existing borrowed-index bounds checks applied to a view. No synchronization is performed.
|
||||
|
||||
| Instruction | Operands/result or continuations | Ownership/memory/transfer | Effects/capabilities |
|
||||
|---|---|---|---|
|
||||
| `buffer.new T %capacity, %cap, ok -> @ok, err -> @err` | usize, cap<mem.alloc>; ok(buffer<T>), err(alloc_error) | new initialized empty prefix; no consumed input; successful result owned | mem.alloc, explicit mem.alloc cap |
|
||||
| `%n = buffer.len %borrow` / `%n = buffer.capacity %borrow` | ref<buffer<T>> or mut<buffer<T>> → usize | shared metadata read through live borrow, no consumption | — |
|
||||
| `buffer.reserve %borrow, %capacity, %cap, ok -> @ok, err -> @err` | mut<buffer<T>>, usize, cap<mem.alloc>; ok(), err(alloc_error) | exclusive metadata/storage access; charge new backing before releasing old; failure preserves buffer; borrow remains live on both edges | mem.alloc, explicit mem.alloc cap |
|
||||
| `buffer.push %borrow, %value, ok -> @ok, err -> @err` | mut<buffer<T>>, T; ok(), err(T) | exclusive access; linear input consumed on both edges; success appends, failure returns original value; borrow remains live | — |
|
||||
| `buffer.pop %borrow, ok -> @ok, err -> @err` | mut<buffer<T>>; ok(T), err() | exclusive access; success removes/owns last value; empty preserves prefix; borrow remains live | — |
|
||||
| `%view = buffer.view %borrow` | ref<buffer<T>> → slice<T>; mut<buffer<T>> → slice_mut<T> | child borrow of initialized prefix, same shared/exclusive mode and provenance; MUST explicitly end; no ownership transferred | — |
|
||||
| `buffer.free %buffer, ok -> @ok, err -> @err` | buffer<T>; ok(), err(buffer<T>) | linear handle consumed on both edges; empty frees/releases charge, nonempty returns same complete buffer; live descendant borrows/task loans reject | — |
|
||||
|
||||
Verifier transfer uses existing whole-value availability for new/free and returned linear block parameters, and useThrough/child provenance for borrowed operations. Length/capacity/view are shared/exclusive access as declared above; all modifying operations require exclusive access even for an empty/full/no-op dynamic case (E2101/E4101). Runtime observes L/C, updates the initialized prefix atomically per instruction and selects the corresponding continuation deterministically. Allocation overflow/exhaustion selects err(alloc_error); no user value is destroyed by a failing operation. Local/borrow/task-bound element types, mismatches and copy/overwrite of linear contents reject E1001; cyclic ownership rejects E1003. Existing resource-leak/repeated-consumption errors apply. No new diagnostic/effect/capability/trap is introduced.
|
||||
@@ -120,6 +120,7 @@ The **accounted size** of a type is a normative, platform-independent metric of
|
||||
| enum | `tag + ` the largest sum over one variant's payload, where `tag` is the smallest of 1, 2, 4, 8 bytes that can hold the index of every variant |
|
||||
| `ref<T>`, `mut<T>` | 8 |
|
||||
| `slice<T>`, `slice_mut<T>` | 16 |
|
||||
| `buffer<T>` (linear_buffers) | 24 |
|
||||
|
||||
`void`, `never` and storage types (`local<T>`) are not materializable values and have no accounted size; the `T` inside a storage type does.
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ The AIR spellings are used (spec 07 §8):
|
||||
- integers `u8`…`u128`, `usize`, `i8`…`i128`, `isize`; `bool`, `void`, `never`;
|
||||
- named types;
|
||||
- `ref<T>`, `mut<T>`, `slice<T>`, `slice_mut<T>`;
|
||||
- `own<T>`, `own_array<T>`, `region`;
|
||||
- `own<T>`, `own_array<T>`, `buffer<T>` (§17), `region`;
|
||||
- `cap<K>`;
|
||||
- `file<read|write|append>`, `listener`, `stream`;
|
||||
- `task<T>`, `sender<T>`, `receiver<T>`, `mutex<T>`;
|
||||
@@ -487,7 +487,7 @@ Standard enum types are named by their full path, for example `std.bytes.ReadU32
|
||||
|
||||
A constructor or pattern is written `std.bytes.ReadU32::ok(value)` or `std.bytes.ReadU32::short_input`. Constructors, payload typing and exhaustive enum matches obey §5/§6 without a library-specific exception. A wrong payload or variant from another enum is `E7005`, an unknown variant `E7002`, a missing arm `E7004`, and duplicate/wildcard enum arms `E7006`. These are ordinary Copy enum values; this increment does not add a must-use or linear-result rule. Source type diagnostics MUST name standard types by their public qualified source path, including inside compound types; AIR output still uses the generated identifiers. Library source uses the same full type paths in signatures, constructors and matches. Standard types lower with the collision-free naming rule above; their declarations precede function declarations as in §2.
|
||||
|
||||
The standard registry exports ordinary enums and generic enum templates (§15). Qualified named types and enum variants introduce no member methods, reflection, dependency resolution or aliases. Generic standard forms use §15. Package modules and qualified struct literals are specified in §14.
|
||||
The standard registry exports ordinary structs/enums and their generic templates (§15). Qualified named types and enum variants introduce no member methods, reflection, dependency resolution or aliases. Generic standard forms use §15. Package modules and qualified struct literals are specified in §14.
|
||||
|
||||
## 14. Package source modules
|
||||
|
||||
@@ -499,7 +499,7 @@ Each mapped source MUST declare exactly its mapped module name. An imported sour
|
||||
|
||||
Imports form an acyclic directed graph. The linker MUST parse each reachable module once, reject self-import/cycles, duplicate imports, duplicate mappings and mismatched headers with `E7006`, and unknown imports with `E7002`. Source syntax errors in a package module use `E7001` at that module's file/line/column. Imports are visited in source order for first-error selection; all complete non-generic declarations of reachable modules, including unused functions, enter verification; templates follow §15. Unreachable mapped source is not parsed or linked. Compiler input limits are 1,024 mapped modules and import depth 256; exceeding them is `E7006`. These are fixed implementation input limits, not runtime fuel or semantics-changing flags.
|
||||
|
||||
Module names use source paths. The first component of a package mapping MUST NOT be `std` or a namespace of a built-in operation (`slice`, `own`, `region`, `cap`, `task`, `channel`, `mutex`, `island`, `frozen`, `arc`, `atomic`, or the first component of a registered intrinsic). Such a mapping is `E7006` (a manifest error at the CLI). Root source names retain their existing grammar; duplicate entry/module identity is rejected when imported.
|
||||
Module names use source paths. The first component of a package mapping MUST NOT be `std` or a namespace of a built-in operation (`slice`, `own`, `buffer`, `region`, `cap`, `task`, `channel`, `mutex`, `island`, `frozen`, `arc`, `atomic`, or the first component of a registered intrinsic). Such a mapping is `E7006` (a manifest error at the CLI). Root source names retain their existing grammar; duplicate entry/module identity is rejected when imported.
|
||||
|
||||
### 14.2 Names and types
|
||||
|
||||
@@ -529,7 +529,7 @@ Templates are parsed and declaration parameter/constraint/duplicate rules, signa
|
||||
|
||||
### 15.2 Structural constraints
|
||||
|
||||
Constraints are requirements on concrete types, not compiler authority to infer effects or repair ownership. `Copy` follows existing value duplication: scalars, built-in enums, capabilities, `iref` and aggregates of Copy values; borrows and linear values are not Copy. `Send` and `Share` use exactly spec 04 §35. In format 0, `Freeze` is exactly `IslandSafe` (spec 03 §22): plain content accepted by deep graph conversion, including `iref`; it does not promise conversion of owners/resources/wrappers. `Local` identifies context-bound `task`, `scope`, `shield` and `guard` (and internal local storage); it propagates through borrows, own/own_array/mutex wrappers and arrays/aggregates containing Local content. Scalars, authority, resources, regions, endpoints and graph owners/handles are not Local. Local is not the complement of Send. No unsafe/manual property declarations are added.
|
||||
Constraints are requirements on concrete types, not compiler authority to infer effects or repair ownership. `Copy` follows existing value duplication: scalars, built-in enums, capabilities, `iref` and aggregates of Copy values; borrows and linear values are not Copy. `Send` and `Share` use exactly spec 04 §35. In format 0, `Freeze` is exactly `IslandSafe` (spec 03 §22): plain content accepted by deep graph conversion, including `iref`; it does not promise conversion of owners/resources/wrappers. `Local` identifies context-bound `task`, `scope`, `shield` and `guard` (and internal local storage); it propagates through borrows, own/own_array/buffer/mutex wrappers and arrays/aggregates containing Local content. Scalars, authority, resources, regions, endpoints and graph owners/handles are not Local. Local is not the complement of Send. No unsafe/manual property declarations are added.
|
||||
|
||||
A type can satisfy several constraints; each requirement MUST be checked. Constraints add no operations or trait dispatch: a body using arithmetic with `T: Copy` still requires an arithmetic-compatible concrete specialization. Effects, `from`, `move`, lends and cleanup remain explicit in every specialization.
|
||||
|
||||
@@ -548,3 +548,14 @@ Structs, enums and fixed arrays with linear members MUST obey spec 03 §25. Cons
|
||||
`value.swap(mut place, move replacement)` returns the previous complete value and stores the replacement; it lowers to value.swap with the existing borrow scope. The same spelling accepts Copy replacements without move. The caller MUST explicitly consume a returned linear value. `match own.pack(move value, heap) { ok(owner) => …, err(error, value) => … }` makes allocation authority/failure explicit and preserves ownership on both outcomes; `or trap` retains ordinary abnormal-path semantics. own.new/own.array/region storage and local storage remain Copy-only; own.take extracts whole linear content and own.free cannot destroy it.
|
||||
|
||||
The frontend MUST declare linear_aggregates plus its dependencies whenever any emitted aggregate has linear members or any of the new operations is emitted. Existing Source/AIR diagnostics and deterministic behavior apply. This phase does not implement partial moves, borrowed aggregates, dynamic linear buffers or source from-returns.
|
||||
|
||||
|
||||
## 17. Source dynamic buffers
|
||||
|
||||
`buffer<T>` is the linear initialized-prefix owner of spec 03 §26. Built-ins use ordinary explicit borrows, moves and outcome matches: `buffer.new<T>(capacity, heap)`, `buffer.len(b)`, `buffer.capacity(b)`, `buffer.reserve(b, capacity, heap)`, `buffer.push(b, move value)`, `buffer.pop(b)` and `buffer.free(move owner)`. Except new/free, b MUST be a named ref/mut<buffer<T>> binding, borrowed first from an owner or aggregate field. Mutating operations require mut. len/capacity accept ref or mut. new/reserve declare mem.alloc explicitly. push requires no heap capability and never grows implicitly.
|
||||
|
||||
Outcomes: new has ok(buffer)/err(alloc_error); reserve has ok()/err(alloc_error); push has ok()/err(original_value); pop has ok(value)/err(); free has ok()/err(original_buffer). Ordinary exhaustive outcome matching/or trap applies. A returned linear value MUST be explicitly consumed. `ref values = buffer.view(b);` binds a shared slice from ref or mut b; `mut values = buffer.view(b);` requires mut b and binds an exclusive slice. The child borrow lasts for its explicit lexical scope and never escapes through an aggregate. This is a primitive borrow binding like graph access, not a general function returning a borrow (Q-034 remains open). Existing indexing/value.swap provides Copy reading and complete linear element exchange. Views expose only the initialized prefix; mutation/growth/free while a view or task loan is live MUST reject even on a dynamically full/empty/no-op branch.
|
||||
|
||||
A specialized generic body MAY use `move name` to express complete value transfer for a type parameter. If its concrete binding is Copy, lowering passes the existing Copy value and it remains available; if linear, ordinary transfer/availability applies. This rule applies to complete Copy bindings inside a specialized generic body, not borrows/storage/function-bound values. Outside a specialized generic body, move of a Copy value remains E7006. No AIR ownership rule changes and no implicit destructor/allocation is added. This makes one generic container body correct for both Copy and linear contents; ordinary borrow/effect/type constraints still apply to every specialization.
|
||||
|
||||
The frontend MUST emit linear_buffers and its full dependencies for buffer types/operations. Existing syntax suffices apart from admitting the buffer wrapper and the typed built-in allocator with the existing channel.make<T> type-argument form. General methods, borrowed aggregate storage, recursive ownership and from-return calls are not added.
|
||||
@@ -10,7 +10,7 @@ APIs SHOULD offer one canonical operation for a common need, small documentation
|
||||
|
||||
## 2. Bootstrap module registry
|
||||
|
||||
The built-in registry contains `std.bytes`, `std.encoding.base64`, `std.encoding.hex`, `std.fmt`, `std.math`, `std.option`, `std.result` and `std.utf8`. They are implemented in safe `.aji` with `effects []`; their stable source paths are `std/bytes.aji`, `std/encoding/base64.aji`, `std/encoding/hex.aji`, `std/fmt.aji`, `std/math.aji`, `std/option.aji`, `std/result.aji` and `std/utf8.aji`, respectively. Spec 15 §13 defines imports; the reference API tables are in `reference/std.md`. All operations are deterministic in every profile, have no concurrency effects and allocate no heap memory. Ordinary interpreter fuel limits apply.
|
||||
The built-in registry contains `std.bytes`, `std.encoding.base64`, `std.encoding.hex`, `std.fmt`, `std.math`, `std.option`, `std.result`, `std.utf8` and `std.vec`. They are implemented in safe `.aji`; their stable source paths are `std/bytes.aji`, `std/encoding/base64.aji`, `std/encoding/hex.aji`, `std/fmt.aji`, `std/math.aji`, `std/option.aji`, `std/result.aji`, `std/utf8.aji` and `std/vec.aji`, respectively. Spec 15 §13 defines imports; the reference API tables are in `reference/std.md`. All operations are deterministic in every profile and have no concurrency effects. Modules other than std.vec declare effects [] and allocate no heap memory. std.vec new/reserve declare mem.alloc and require explicit allocation authority (§2.10); its other functions allocate no heap. Ordinary interpreter fuel limits apply.
|
||||
|
||||
### 2.1 `std.math`
|
||||
|
||||
@@ -150,3 +150,14 @@ enum Result<T, E> { ok(T), err(E) }
|
||||
`std.option.is_some<T: Copy>(value: Option<T>) -> bool` and `std.result.is_ok<T: Copy, E: Copy>(value: Result<T, E>) -> bool` declare `effects []`, allocate no heap and classify the active variant. They neither extract nor implicitly consume any payload. Call them using spec 15 §15's explicit expression arguments, e.g. `std.option.is_some::<u64>(value)`. Types/constructors/patterns are fully qualified and require a direct import; exhaustive matches extract payloads through ordinary enum rules. `none` still requires a type argument. `err(E)` is an ordinary enum variant, not the intrinsic outcome shorthand.
|
||||
|
||||
Option/Result accept ordinary complete value payloads, including owners/resources/endpoints under linear_aggregates (spec 03 §25, source §16). Their class is structural: an owning specialization is linear even when the active variant is none or a Copy error. It MUST be explicitly moved and exhaustively consumed; unused linear payloads reject E3002. Borrow/storage/function-bound payloads remain forbidden by ordinary member/type rules. is_some/is_ok retain Copy constraints and MUST reject E7005 for linear arguments; they do not consume a resource merely to classify it. Match an owning value explicitly instead. Existing Copy specializations retain behavior. No implicit unwrap/default/conversion or cleanup is added.
|
||||
|
||||
|
||||
### 2.10 Explicit owning vectors
|
||||
|
||||
Compiler-pinned `std.vec` MUST provide `Vec<T> { storage: buffer<T> }` and ordinary result enums: NewResult<T> { ok(Vec<T>), err(alloc_error) }, PushResult<T> { ok, full(T) }, ReserveResult { ok, err(alloc_error) }, FreeResult<T> { ok, not_empty(Vec<T>) }, ReplaceResult<T> { ok(T), out_of_bounds(T) }. All payloads follow ordinary complete-value/linearity rules; no implicit destruction occurs. Fields are ordinary visible source fields, not an opaque trusted container.
|
||||
|
||||
Public functions use explicit `::<T>` specialization: new<T>(capacity:usize,heap:cap<mem.alloc>)→NewResult<T>; len<T>(value:ref<Vec<T>>)→usize; capacity<T>(value:ref<Vec<T>>)→usize; reserve<T>(value:mut<Vec<T>>,capacity:usize,heap:cap<mem.alloc>)→ReserveResult; push<T>(value:mut<Vec<T>>,item:T)→PushResult<T>; pop<T>(value:mut<Vec<T>>)→std.option.Option<T>; free<T>(value:Vec<T>)→FreeResult<T>; get<T:Copy>(value:ref<Vec<T>>,index:usize)→std.option.Option<T>; replace<T>(value:mut<Vec<T>>,index:usize,item:T)→ReplaceResult<T>. Only new/reserve declare effects [mem.alloc]; all other functions declare effects [].
|
||||
|
||||
These are safe `.aji` wrappers over spec 03 §26. new chooses exact initial capacity, reserve chooses a minimum capacity without shrinking, and push never grows implicitly. len/capacity observe initialized length/backing capacity. pop removes the last complete value, returning none for empty. A full push returns the original item. get copies an in-bounds Copy item or returns none. replace exchanges an in-bounds initialized element and returns the previous item; out_of_bounds returns the original supplied item and preserves the vector. free releases only an empty vector; otherwise it returns the same vector. Returned owning result specializations need exhaustive match move; Copy results use ordinary matching. Callers drain and explicitly consume resource payloads before freeing.
|
||||
|
||||
Capacity/allocation failure, alias/task exclusion, deterministic profiles and diagnostics are those of buffer primitives and ordinary enum/call rules. Valid complete values include owners/files/endpoints; no collection bypasses Send/Share or channel_transfer gates. Imports grant no authority. Deque/HashMap/HashSet/BinaryHeap, owning strings and general borrowed function returns remain separate increments of STD-6.
|
||||
Reference in new issue
Block a user