Standard library

Every module is a TryC source file of the standard library, written in TryC (with asminline for the syscalls and the SIMD paths). #include <libstd/name> makes it available; a module may include others, and including the same file twice is harmless. The pages in this section are generated from the sources: signatures, classes and constants are always current.

Linux and Windows

A program that uses the standard library compiles unchanged for Linux and for Windows: every module has the same functions, classes and constant names on both. What changes is underneath. A module that needs the operating system includes its back end with the macros the compiler predefines for the target:

#ifdef __unix__
#include <libstd/wrapper/linux/sysnet>
#else
#include <libstd/wrapper/windows/sysnet>
#endif

The two back ends define the same sys_* functions: on Linux they are system calls, on Windows calls to the Windows API (kernel32, ws2_32, bcrypt, user32, ...). The functions without the prefix are written once, above them, and are the same code on both. A constant whose number depends on the system, like a socket option, is defined in both back ends with the same name; the reference pages show the two values side by side.

When something exists on only one system, the other one gets the closest equivalent (TCP_USER_TIMEOUT is TCP_MAXRTMS on Windows). If it is only an optimisation, it does nothing there (TCP_DEFER_ACCEPT on Windows). If skipping it would change what the program does, it stays on one system and using it on the other is a compile error (SO_REUSEPORT, libstd/xlib). exit ends the whole process on both, threads started by a library (such as a Vulkan driver's) included.

Core

ModuleContents
stdioprint, buffered input, fprint, raw read/write
stringlength, search, slicing, strip, split/join, replace, line Reader
typethe conversions as does not do: narrowing integers, text to number, digits, hexadecimal
listgrowable List of long
dicthash tables: dict (int), sdict (str), vdict (typed), adict (boxed, nestable); iteration; peek/poke
jsonparse and serialise JSON
mathsin/cos/sqrt, Vec3, 4×4 matrices
randomxorshift64* generator, entropy from the system
reregular expressions: search, groups, findall, sub, compiled patterns
argparseArgParser: command-line options, flags, positionals, subcommands, --help; several parsers on one command line

Operating system

ModuleContents
fileopen/close/stat, whole-file read, dup, flags and modes
osargv, environment, cwd, uname, executable path, sysinfo
processpids, fork/exec/wait, system, zombie reaping, clone
threadthread_spawn, thread_join/thread_detach, cooperative stop
syncatomics and futexes
netTCP sockets, socket options
httpHTTP/1.1 server: routes, static files, middleware, cookies, shared sessions, worker processes with epoll
http/cookiesthe cookies of a request and of its response: read, set, delete, safe defaults
http/sessionsessions shared by all the workers: login and logout, expiry, recovery after a crash
timeclocks, timestamps, sleep, durations
windowa window on the screen and its close button (Xlib on Linux, user32 on Windows)
memmemory syscall and mmap constants
macro__unix__ and syscall numbers
cpuinfovendor, brand, features: cpuid on x86_64, ID registers on aarch64

Bindings to C libraries

ModuleLinuxWindows
sqlite3libsqlite3.sowinsqlite3.dll
mysqllibmariadb.solibmariadb.dll (on PATH)
xliblibX11.so.6, with events— (use window)
vulkan, vulkan3dlibvulkan.sovulkan-1.dll

Conventions