CEP-0046: Standard Collections¶
Draft
Draft proposal for concrete standard collection types. V1 accepts only std.collections namespace ownership.
Summary¶
Catalyst should eventually design concrete dynamic arrays, maps, sets, queues, and collection adapters in std.
V1 only records the namespace skeleton and contract families needed by source semantics. It does not accept concrete collection declarations.
Example¶
Possible future shape:
fn dump_values(alloc: *impl Allocator, out: *impl std.io.Writer) void! {
var values = std.collections.Vec(i32).create(alloc)
try values.push(10)
try values.push(20)
for value in values.iter() {
try std.fmt.write(out, "{}", value)
}
}
The proposal must define allocator ownership, failure behavior, iteration, borrowing, formatting, and cleanup. The out writer in this example is an explicit IO capability supplied by the caller.
Motivation¶
Collections are essential standard-library surface. They need allocator policy, ownership behavior, iteration, hashing, equality, ordering, and realtime suitability decisions.
Proposed Direction¶
The proposal should cover:
- dynamic arrays;
- maps and sets;
- queues and adapters;
- allocator ownership and failure behavior;
- iteration and borrowing rules;
- interaction with
std.hash, equality, ordering, and formatting.
V1 Compatibility¶
V1 does not require or accept full concrete collection APIs. The active V1 standard-library skeleton reserves std.collections as the future home for concrete collections and adapters, but it does not define Vec, maps, sets, queues, buffers, iterator adapters, or collection helper APIs.