# Stdlib
The stdlib is the set of native functions compiled into every Deft
runtime (implemented in Zig under `src/host/plugins/` and
`src/host/stdlib/`) and registered before any script runs. They need no
import and are available in every host — the `deft` scripting binary,
`retro`, `retra`, and `hydra`.
Do not confuse the stdlib with stdext (`deft/stdext`), the
Deft-language extension package that ships `html`, `markdown`, `syntax`,
`semantic`, themes, and the TUI plumbing. stdext is imported like any
other package (see
Modules and Imports); stdlib
functions are simply there.
This category is the catalogue, organised by namespace — one page per
function family. Language-level semantics for the collection functions
live in Collections,
Lazy Sequences,
Transducers, and
Error Handling.
## How To Read This Page
Each entry lists the function name, argument shape, and brief purpose.
The canonical form for invocation depends on context — see
Syntax and Style. Quick rules:
- Bare names work at statement position for top-level calls:
`echo $x`, `incr i`.
- Postfix `$var(call)` works for single-arg calls on a variable:
`$x(len)`, `$xs(first)`.
- Prefix `[name args]` is canonical and required inside larger
expressions or for slash-namespaced calls:
`[fs/read "path"]`, `[sqlite/query $db "sql"]`.
## Function Families
| Page | What it covers |
|---|---|
| I/O | `echo`, `puts`, `gets`, `open`, `close`, `log` — channels and streams |
| Math | Bare numeric verbs plus the specialised `math/` namespace |
| Strings | Core string ops, display-width layout, raw bytes |
| Types | `type`, `is?`, predicates, coercion, metadata |
| Schema | `schema/*` — validate and convert values against deftype schemas |
| Results | `ok` / `err`, predicates, `unwrap`, `throw` |
| Refs | Mutable state cells and watches |
| Lists | Persistent list operations |
| Maps | Persistent map operations, tagged maps, nested access |
| Arrays | Mutable arrays |
| Sets | Set operations |
| Sequence Functions | Lazy `map` / `filter` / `reduce` and friends |
| Utility | `identity`, `apply`, `curry`, `eval`, `reload`, `pretty` |
| Chars | Character classification predicates |
| Clock | TCL-style time and formatting |
| Regex | PCRE2 regular expressions |
| Logging | Levelled `log/*` verbs |
| Filesystem | `fs/*` — read, write, watch, paths |
| OS | `os/*` — process, environment, subprocesses, signals |
| Data Formats | `json/*` and `yaml/*` |
| XML | `xml/*` — parse, build, and serialize XML documents |
| HTML | `html/*` — parse, query (CSS selectors), and extract text from HTML |
| Crypto | Hashing, HMAC, encoding, symmetric crypto |
| Compress | gzip, tar, and tarball helpers |
| Theme | Load, edit, and save theme files |
| Introspection | `deft/*`, `info/*`, `capture/*`, `capabilities` |
| Tasks | Stream and future consumer verbs |
## Namespaces With Their Own Guides
Several namespaces are large enough that their manual chapters live with
the platform, network, or tooling topic they belong to:
| Namespace | Guide |
|---|---|
| `vfs/*` | VFS |
| `sqlite/*` | SQLite |
| `config/*` | Configuration |
| `pub/*` | Pubsub |
| `runtime/*`, `gc/*` | Runtimes |
| `rpc/*` | RPC |
| `pg/*` | PostgreSQL |
| `net/*` | TCP/UDP |
| `http/ws-*` | WebSockets |
| `dns/*` | DNS |
| `http/*` (client) | HTTP Client |
| `http/*` (server) | HTTP Server |
| `mcp/*` | MCP |
| `dialog/*` | Dialogs |
| `tui/*`, `draw/*`, `surface/*`, `scene/*`, `gl/*`, `color/*`, `clipboard/*`, `editor/*`, `term/*` | TUI Overview, Graphics |
| `pkg/*` | Packages |
| `debug/*` | Debug Server |
| `ffi/*` | FFI |
Smaller namespaces (`assert/*`, `keymap/*`, `keyval/*`, `lang/*`,
`uuid/*`, `bin/*`, `image/*`, `dbus/*`, `worker/*`, `import/*`, and the
rest) are documented per symbol in the Help app's Reference tab,
alongside the `packages/help/docs/` files in the source tree.
## Availability
The core namespaces are compiled into every build. A few are gated:
- TUI hosts (`retro`, `retra`, built with `-Denable-tui=true`) add
the `tui/*`, `draw/*`, `surface/*`, `scene/*`, `gl/*`, `color/*`,
`clipboard/*`, `editor/*`, and `term/*` namespaces.
- FFI builds (`-Dffi=true`) add `ffi/*`.
- `dialog/*` exists everywhere, but the scripting binary renders it on
stdin/stdout while the TUI hosts draw real dialogs.
## Discovering Stdlib Functions at Runtime
[capabilities] # what's compiled in [info/modules] # what's loaded [info/defs] # defs in the current ns
For up-to-date listings, the canonical sources are the plugin files
under `src/host/plugins/` and `src/host/stdlib/` in the codebase. The
plugin registry is auto-generated at build time.