Standard Library: Vec
std.vec is a growable Vec over i64-shaped slots, written entirely in MIND. It bottoms out in seven host-supplied __mind_* intrinsics, so there is no built-in pointer type, no hidden allocator, and no implementation magic above the intrinsic layer.
mindc 0.4.0+; as of mindc 0.7.1 the std-surface layer is the shipped default (no opt-in flag). Auto-bundled into the compiler since 0.4.2 so use std.vec resolves with zero external file dependency.Layout
- Struct (heap record): three
i64fields —data_addr,len,cap. - Stride: 8 bytes per slot.
- Growth: doubling, starting at 16 slots.
- Allocation:
__mind_allocon construction,__mind_reallocon growth,__mind_freeon drop.
Public API
vec_new() -> Vecvec_push(v: Vec, x: i64) -> Vecvec_pop(v: Vec) -> (Vec, i64)vec_get(v: Vec, i: i64) -> i64vec_set(v: Vec, i: i64, x: i64) -> Vecvec_len(v: Vec) -> i64vec_capacity(v: Vec) -> i64vec_free(v: Vec) -> i64
Example
use std.vec;
fn main() -> i64 {
let v = vec_new();
let v = vec_push(v, 10);
let v = vec_push(v, 20);
let v = vec_push(v, 30);
let n = vec_len(v); // 3
let x = vec_get(v, 1); // 20
vec_free(v);
return x;
}Every operation returns the (possibly reallocated) Vec handle — there is no hidden mutation. The use std.vec declaration resolves against the bundled stdlib, with last-write-wins shadowing if your crate defines its own std.vec module.
Intrinsics this rests on
__mind_alloc(size: i64) -> i64__mind_realloc(addr: i64, new_size: i64) -> i64__mind_free(addr: i64) -> i64__mind_load_i64(addr: i64, offset: i64) -> i64__mind_store_i64(addr: i64, offset: i64, value: i64) -> i64
Forking the stdlib (Phase D)
Set MIND_STDLIB_PATH=path/to/stdlibto override the bundled blobs at project-load time — the project loader will read vec.mind, string.mind, map.mind, and io.mind from that directory instead. Missing files, missing directory, or parse failure silently fall back to bundled.
Use case: a regulated deployment that needs a stricter std.string (inline UTF-8 validation, length bound) without forking mindcitself. Same fork-without-recompile escape hatch Rust’s RUSTC_BOOTSTRAPprovides. Shipped in mindc v0.4.3 (RFC 0005 Phase D₁). Phase D₂a (mindc v0.4.4) adds a diagnostic refinement: arity/type errors on imported pub fns preserve Named struct parameter names rather than collapsing them to the lowered ScalarI64ABI (e.g. “expects Vec (heap-record i64 addr), got tensor<f32[3]>”).