Memory Model & SafetyM3
Value Semantics & Arena Lifetimes
GC-free function, loop, and HTTP request arenas with return promotion and early reclamation.
6 min readUpdated: v0.8.0-rc Reference
No Garbage Collector, No Raw Pointers
HADID pairs value semantics with hierarchical arena ownership:
- Function Regions: Each call allocates temporaries in a child arena. Returned strings, arrays, lists, or nested structs/sum types are promoted into the caller's arena on return, and the child region is reclaimed immediately.
- Loop Lifetimes: Per-iteration scratch allocations reset each cycle. M3 tests verify flat peak memory across 1,000 vs. 10,000 iterations (48/48 equal peaks) under ASan/UBSan.
- HTTP Request Arenas:
web_acceptresets the per-request arena on every incoming connection.
hadid · EN
fn append_tag(items: List<string>): List<string> { return list_append(items, "scoped-copy");}let origin = List<string>.Empty;origin = list_append(origin, "original");let derived = append_tag(origin);print("origin length: " + json_from_i64(length(origin)));print("derived length: " + json_from_i64(length(derived)));print("derived[1]: " + derived[1]);assert(length(origin) == 1, "caller list must stay untouched");