Core Built-ins and Standard Libraries
seed keeps the language core small. Files, networking, processes, formatting, collections, and synchronization are ordinary separately compiled libraries, not universal built-ins. The clean compiler's built-in surface is below; the operational compiler-staged package catalog is documented in Library Reference, while the mixed-generation Grove tree is classified separately in Grove Compatibility Tree.
Core types
The compiler defines void, never, bool, fixed-width integers, isize,
usize, f32, f64, str, string, bytes, shared_bytes, alloc_error,
and the hidden region_handle. byte is accepted as u8.
alloc_result<t> is the canonical shorthand for
result<t, alloc_error>. Hosted main() -> result<i64, e> maps success to the
process status. alloc_error has the fixed diagnostic; another e must be
Copy, have no destructor, and implement borrowed display() -> str. Failure
is printed once before status 1, after cleanup and without unwinding.
Safe compiler-known operations
| Operation | Contract |
|---|---|
len(value) |
usize byte/element length for str, string, bytes, shared_bytes, slices, and arrays |
str.bytes() |
allocation-free read-only []u8 view with the source provenance |
slice.slice(start, count) |
checked allocation-free subview preserving element type and mutability |
mut_slice.split_at_mut(index) |
checked allocation-free pair of exclusive, non-overlapping lexical views |
mut_slice.fill(value) |
fills a Copy-element slice without allocation |
mut_slice.copy_from(source) |
equal-length, overlap-safe Copy-element transfer without allocation |
bytes.into_prefix(length) |
consuming checked logical truncation that reuses the allocation and capacity |
some(value) / none |
canonical option construction; none needs expected ?t |
result.ok(value) / result.error(problem) |
canonical result construction with expected result<t,e> |
option.is_some() / option.is_none() |
allocation-free borrowed inspection |
result.is_ok() / result.is_error() |
allocation-free borrowed inspection |
option_or_result.unwrap_or(value) |
consuming default with exact cleanup of the unselected owned value |
or_abort() / expect(message) |
explicit non-unwinding fatal boundary |
or_exit(status) |
main-only i64 option/result boundary using ordinary cleaned-up return |
value.clone() |
explicit structural clone when capability exists; allocation effect is tracked |
string.view() |
allocation-free borrowed str |
bytes.view() |
allocation-free read-only []u8 |
bytes.mutable_view() |
exclusive lexical mut []u8 covering the full allocated length |
bytes.zeroed(length) |
fallible zero-initialized result<bytes, alloc_error>; length must be i64 |
unsafe { bytes.uninitialized(length) } |
fallible internal-capacity allocation; callers must initialize every byte before exposing a prefix |
shared_bytes.view() |
allocation-free read-only []u8 |
array.view() / array.mutable_view() |
explicit allocation-free compatible slice; mutable view requires a mutable owner |
str.equal(other) |
allocation-free UTF-8 byte comparison |
str.find_ascii(delimiter, start) |
checked allocation-free delimiter search; non-ASCII delimiters rejected |
byte_slice_equal(a, b) |
allocation-free []u8 length-and-content equality |
sqrt(value) / abs(value) / min(a, b) / max(a, b) |
f32/f64 math operations |
str.slice(start, count) |
checked zero-copy subview preserving provenance |
slice.slice(start, count) |
generic checked zero-copy []t subview preserving provenance |
byte_view.equal(other) |
allocation-free []u8 length-and-content equality |
str.to_string() / string.from(view) |
result<string, alloc_error>; explicit allocation |
str.to_bytes() / bytes.from(view) |
result<bytes, alloc_error>; explicit copy/allocation |
bytes.to_shared() / shared_bytes.from(data) |
consume owned bytes; result<shared_bytes, alloc_error> |
region(capacity) { body } |
lexical checked bump-allocation scope |
io.input_stream.read(chunk) |
bounded fallible partial read; callers can process EOF/data incrementally without retaining all input |
Safe indexing of arrays/slices accepts every builtin integer width and checks the mathematical index before pointer formation. Text APIs expose bytes; Unicode scalar/grapheme processing belongs in libraries.
Known limitation: variable-index reads (buf[i] where i is a variable)
are not supported on mut []u8 or on sub-slices derived from []u8 via
.slice(). Fixed-index reads (buf[0]) work on all slice types. Direct
[]u8 function parameters and the original slice from bytes.view() support
variable-index reads. To work around this limitation, scope mutable views
within a block and use read-only []u8 function parameters or the original
bytes.view() slice for variable-index access.
byte_buffer note: byte_buffer.mutable_view() returns a view of the
initialized prefix, which is length 0 for a freshly created buffer. Writing
past the returned length causes an out-of-bounds trap. To write into a raw
buffer, use bytes.zeroed(n) whose mutable_view() covers the full
allocation, or use byte_buffer methods push/extend/reserve/resize.
Unsafe compiler substrate
The following operations require an unsafe block or unsafe fn:
| Family | Operations |
|---|---|
| typed raw memory | raw_try_alloc<t>, raw_null<t>, raw_is_null<t>, raw_read<t>, raw_write<t>, raw_free<t>, raw_slice<t> |
| atomics | acquire/release helpers plus ordered load/store/fetch-add/exchange/compare-exchange |
| ordering | compiler and atomic fences with validated memory orders |
| devices | typed volatile read/write and address-space casts |
| architecture | typed raw assembly intrinsics |
| interoperability | raw pointers, FFI, syscalls, and raw unions |
raw_try_alloc<t> reports negative count, size overflow, or allocator failure
as alloc_error. Raw read/write/free rely on the audited unsafe caller for
bounds, initialization, provenance, synchronization, and exact-once release.
Ordinary library packages
The clean compiler stages representative packages under compiler/llvm/libs:
| Package | Role |
|---|---|
box |
fallible safe owned indirection for recursive and large values |
byte_buffer |
fallible growable byte construction, mutation, views, and consuming bytes conversion |
file |
hosted output/file wrapper over the runtime ABI |
fibonacci |
allocation-free iterative O(n) i64 Fibonacci with explicit negative/overflow none |
net |
hosted networking wrapper |
io |
typed hosted partial/read-all input, write-all text/bytes/format output, bounded buffering, and print/println for quick output |
math |
portable f32/f64 square root, absolute value, minimum, and maximum |
parse |
checked signed/unsigned integer parsing and explicit default helpers |
process |
allocation-free process arguments, environment views, and process identity |
serialize |
representative safe serialization package |
sort |
scalar mutable-slice sorting and static order_key sorting for move-only values |
slice |
generic allocation-free reverse, rotate, and fixed-width window helpers; core slices provide fill/copy_from |
text |
UTF-8 validation, allocation-free checked Unicode-scalar iteration/counting, owned-string conversion, and ASCII-delimited token cursors |
time |
monotonic hosted milliseconds plus Unix wall-clock seconds/milliseconds |
vec |
fallible generic vector with capacity/filled constructors and @mut reserve/push/update/pop, plus queue, set, and map |
task |
ownership-split channels, typed one-shot and result<t,e> joins, events, cancellation, waitgroups, semaphores, barriers, and locks |
system |
safe systems wrappers over address spaces, MMIO, atomics, pages, DMA, init-once, and CPU-local mechanisms |
The launcher's incremental build/run path automatically stages these repository
core packages when an ordinary package uses a bare import such as use "vec"
or use "fibonacci"; no manual interface installation or application-visible
FFI is required. The narrower check subcommand does not stage a missing bare
package first. Direct compiler users may consume an explicit source or .sdi
package. These are not magical language names.
Formatting and output
The language implements typed phase-1/2 f"..." interpolation. An f-string
yields ephemeral format_args without heap allocation. compiler/llvm/libs/io
is the canonical typed surface for text, byte-slice, and format output. For
quick output, print(text) writes to stdout and println(text) writes
with a trailing newline. .to_string()?
performs explicit fallible materialization. Width/fill/alignment, integer base
specifiers, and allocation-free borrowed display trait formatting are
implemented. Phase 2 adds libc-free f32/f64 fixed,
scientific, and general formatting plus borrowed display/debug traits.
Compatibility warning
llvm-v1 and historical Grove/runtime tables expose many names such as
str_cat, read_file, net_connect, vec_new, and sd_*. Their existence in
an archived compiler does not make them clean compiler built-ins. When porting
legacy code, import or implement a current safe wrapper and let its .sdi
contract define ownership, effects, ABI, and availability.