Builtins
Compiler-provided operations surfaced through builtin expressions and std.builtin.
Builtins are compiler-recognized operations written with @name(...). Most are
expressions. Public ownership helpers are exposed through the auto-preluded
root std namespace, so normal code writes std.drop(value) instead of
calling the legacy/internal @drop(value) spelling directly.
let n = @sizeof(i32);
The current language and standard library use builtins for low-level behavior
such as size queries, memory operations, slice construction, volatile access,
LLVM intrinsics, and ownership metadata. Normal user source has a narrow
surface; compiler/runtime @zynx.* builtins are reserved unless they are
documented here or in the language reference.
| Family | Examples |
|---|---|
| Type and size | @sizeof(T) |
| Memory | @llvm.memcpy, @llvm.memmove, @llvm.memset |
| Slices and strings | @slice_of, @owned_slice, @is_owned, @str_from_raw |
| Pointers | @str_ptr, @ref_ptr |
| Volatile | @zynx.volatile.read<T>, @zynx.volatile.write<T> |
| Ownership | std.copy(value), std.move(value), std.drop(value) |
The root std namespace is auto-preluded. It is a helper namespace, not a
module auto-import mechanism; real modules such as std.io, std.json, and
std.net still need explicit imports.
| Helper | Purpose |
|---|---|
std.copy(value) | Copy a T: Copy value and leave the source usable. |
std.move(value) | Explicitly consume a value, including values whose type is Copy. |
std.drop(value) | Explicitly consume and drop a local owner. |
std.iter(value) | Create the minimal slice/array iterator pipeline. |
std.builtin is compiled into the standard module set. It exports the
compiler-recognized marker interfaces Copy, Integer, Signed, and
Unsigned, plus DynamicError for internal dynamic-loading support. These are
language-reserved surfaces, not ordinary user-extensible APIs.
Volatile access requires unsafe context:
unsafe {
let status = @zynx.volatile.read<u32>(status_reg);
@zynx.volatile.write<u32>(control_reg, status | 1);
}
Volatile is not atomic and is not a synchronization primitive. Atomics are not
part of the normal 0.0.0-dev language.
std.drop(value) manually destroys one local owner and marks that binding as
moved. The lower-level @drop(value) form is kept as compiler/runtime
spelling, but public docs should prefer std.drop.
struct Guard {
id: i32,
drop(self) {}
}
fn main() {
let guard = Guard { id: 1 };
std.drop(guard);
}
Use it when cleanup must happen before the natural lifetime end. Ordinary code
should prefer type destructors, defer, and with; see
RAII and Drop.