Ownership Without a Garbage Collector
Every value has one clear owner. Moves, borrows, and drops are explicit and checked at compile time, so resources release deterministically and use-after-free is rejected before runtime.
Ownership and drop
Explicit ownership, visible errors, and cold async compiled to native code through LLVM.
Fallible behavior is visible from the first program. read_id declares the errors it can raise, and the caller chooses whether to propagate with try or recover with a catch arm per variant.
import std.io;
import std.mem.{ AllocError };
error LoadError {
NotFound,
Denied,
}
fn read_id(fail: bool) throws(LoadError) -> i32 {
if fail {
throw LoadError.NotFound;
}
return 42;
}
fn main() throws(AllocError) {
let id = read_id(false) catch {
.NotFound => 0,
.Denied => -1,
};
io.println(try ^"id={id}");
}Zynx is development software. Public pages describe implemented and documented behavior. Prefer the language chapters when a feature guide and current compiler behavior disagree.