Standard library

A map of the insty standard library — core, std, and the platform namespaces.

The standard library lives next to the compiler and is the module search root. :: is the directory separator, so a module at libs/<dir>/<name>.ins is imported as import <dir>::<name>.

core — freestanding primitives

Target-agnostic, safe in freestanding mode.

  • core::core — runtime intrinsics the compiler relies on (memcpy/memset, formatters, allocator hooks)
  • core::memcopy, set, zero, eq (raw byte operations)
  • core::bits — bit/flag helpers
  • core::bytes — length-tagged, non-owning byte slices

std — hosted modules

Higher-level modules that assume a hosted OS.

  • std::ioprint, println, eprintln, … (raw write syscalls, no libc)
  • std::str — read-only text helpers: len, eq, starts_with, find, to_i64, …
  • std::mathabs, min, max, clamp, sign, pow
  • std::vecVector<T>, a growable generic array (needs an allocator)
  • std::stringString, an owned, growable UTF-8 builder (needs an allocator)
  • std::mapStringMap<V>, a text-keyed hash map (needs an allocator)
  • std::fsopen, read, write, read_file, write_file (raw syscalls)
  • std::alloc, std::fmt, std::ascii, std::parse, std::coff, std::uefi

Platform namespaces

  • windows — Win32 bindings for x86_64_windows, imported straight from system DLLs (windows::core, windows::io, windows::files, windows::mem, windows::ui)
  • instantos — raw InstantOS userland syscalls (instantos::sys, instantos::io, instantos::mem)
  • unix, posix — reserved namespaces the portable std layer will build on

Example

module main

import std::vec

fun main() -> i32 {
    Vector<i32> v = Vector<i32>{}
    v.push(1)
    v.push(2)
    return v.len()      // needs --allocator runtime
}

Anything that allocates (Vector, String, StringMap) requires a heap — build with --allocator runtime or --allocator external.