Standard library
The standard library is written in Tripon and lives in src/stdlib/. It is not
built into the compiler and it is not imported by a keyword: it is a normal local
dependency, folded into your translation unit by ralt.yaml.
name: myapp
version: 0.1.0
deps:
std: ./src/stdlibWith that line, ralt run src/main.tp can call min_i32, unwrap_or_i32,
vec4_push and the rest by plain name. Because dependencies compile into the
same unit, there is no link step and no namespace to write.
Tiers
Modules declare their own ceiling at the top of the file, exactly as programs do:
| module | tier | contents |
|---|---|---|
kernel/math.tp | kernel | min_i32, max_i32, clamp_i32, abs_i32, their i64 twins, gcd_i32, is_prime_i32, sign_i32 |
kernel/bits.tp | kernel | is_even, is_odd, low_byte, high_byte, pack16, unpack16_hi/lo, popcount_u8, parity_u8 |
core/optutil.tp | core | is_some_i32, is_none_i32, unwrap_or_i32, map_or_i32 |
core/resultutil.tp | core | is_ok, is_err, unwrap_or_result, err_or_empty |
core/strutil.tp | core | str_is_empty, str_starts_with, str_count_byte, str_sum_bytes |
core/strcmp.tp | core | str_index_of, str_contains, str_compare, str_equal, str_eq_ci |
core/sortutil.tp | core | sort3_min/mid/max, is_sorted3 |
core/floatutil.tp | core | sqrt_newton, abs_f64, clamp_f64, min_f64, max_f64, powi_f64 |
core/vec4.tp | core | fixed [4]i32 vector: vec4_init/len/push/get/set/sum/max/min/is_full/is_empty |
core/map8.tp | core | fixed i32 -> i32 map (linear probe): map8_put/get/has/del/len/sum_* |
core/queue8.tp | core | fixed FIFO ring: ring8_push/front/pop/len/sum/is_full/is_empty |
core/stack8.tp | core | fixed LIFO: stack8_push/peek/pop/len/sum/is_full/is_empty |
core/buf16.tp | core | fixed [16]u8 buffer: buf16_push/get/set/sum/crc/len/is_full |
The v0 constraint that shapes it
Arrays are function-local: an array cannot be a parameter or a return type. Containers therefore live inside a struct, which is passed by value, and a "mutation" returns the updated struct:
let v = vec4_init(); v = vec4_push(v, 10); v = vec4_push(v, 20); print_i32(vec4_sum(v));
30
This is a copy, not a pointer. For small fixed capacities that is the whole
point — no allocator, no aliasing, no lifetime to get wrong, and the same code
runs at tier core on a microcontroller.
opt carries scalars and structs only in v0, so the option helpers are
specialised (opt<i32>) rather than generic. Generics are a std-tier layer
that has not landed yet; when it does, these names collapse into one Option<T>.
Testing
Every module has a smoke test in tests/cases_std/ with a byte-exact golden in
tests/expected_std/, run by tests/stdlib_smoke.sh through the same
ralt.yaml folding a user would use. tests/cases_std/integration_all.tp
composes math, float, vector, map, stack, buffer and string modules in one
program.