← garnet-lang.org  ·  Getting Started  ·  Mini-Spec  ·  Source ↗

Stdlib Primitive Registry

The current v0.5 registry exposes 24 primitive entries. Pure helpers require @caps(); time, filesystem, and network primitives require explicit authority.

This is a registry reference, not a promise of a mature standard library. Higher-level HTTP, JSON, package, async, and data APIs remain future library work.

24registry entries
13pure helper entries
11authority-gated entries
3authority classes used here

Primitive Table

NameArityCapsDescription
time::now_ms0timeMonotonic clock in milliseconds since process start.
time::wall_clock_ms0timeWall clock in milliseconds since UNIX epoch.
time::sleep1timeSleep the current thread for N milliseconds.
str::split2@caps()Split a string on a delimiter; returns an Array<String>.
str::replace3@caps()Replace all occurrences of old with new.
str::to_lower1@caps()Lowercase a string.
str::to_upper1@caps()Uppercase a string.
str::trim1@caps()Trim whitespace from both ends.
str::starts_with2@caps()Return true if the string starts with the prefix.
str::contains2@caps()Return true if the string contains the substring.
array::insert3@caps()Insert value at index; shifts following elements right.
array::remove2@caps()Remove and return the element at index.
array::sort1@caps()Sort the array in-place.
crypto::blake31@caps()BLAKE3 hash of a byte sequence.
crypto::sha2561@caps()SHA-256 hash of a byte sequence.
crypto::hmac_sha2562@caps()HMAC-SHA-256 of a byte sequence with a given key.
fs::read_file1fsRead a UTF-8 file as String.
fs::write_file2fsWrite a String to a file, creating or truncating.
fs::read_bytes1fsRead a file as Bytes.
fs::write_bytes2fsWrite Bytes to a file, creating or truncating.
fs::list_dir1fsList entries in a directory.
net::tcp_connect2netOpen an outbound TCP connection.
net::tcp_listen1netOpen a TCP listener on a local port.
net::udp_bind1netBind a UDP socket on a local port.

What Is Still Missing

A production-feeling language needs more than this registry. The next useful layers are JSON, HTTP client/server helpers, regex, UUID, datetime, structured logging, configuration, package manifests, and richer test helpers. Those should land behind the same capability discipline, with examples and dogfood evidence beside the implementation.