Routines
Everything callable in ReifyDB is a routine, and there are two kinds. Functions are pure computations used inside expressions; procedures run statements, may write, and are invoked with CALL. Both answer to the same namespace::name addressing. This page is the map; the linked references go deep.
One naming scheme
Every routine has a qualified name of the form namespace::name - math::abs, text::upper, clock::now. Built-ins register under fixed namespaces when the engine boots, and those names are stable: they appear in stored queries, scripts, and client code, so ReifyDB adds new routines rather than renaming existing ones. Your own procedures live in your own namespaces, addressed exactly like your tables.
Variants of a function are separate flat names with underscore suffixes, not deeper namespaces: the saturating sibling of math::add is math::add_saturate, and the none-on-overflow one is math::add_none. The arithmetic policy suffixes (_saturate, _wrap, _zero, _none, _default, _strict) are the largest such family; see Arithmetic Policies.
Functions: values in, values out
Functions are pure. They transform input values into output values and touch nothing else, which is what makes them safe anywhere an expression is expected: in map, filter, extend, aggregate. Nearly 200 built-ins ship in domain modules - math, text, date, datetime, duration, time, blob, json, is, and more - each documented in the function reference.
Most functions are scalar: one output value per row. Some are aggregates - math::sum, math::avg, math::count - and fold a whole group into one value inside aggregate. A few are generators that produce rows instead of transforming them, such as series::generate standing as a FROM source.
Procedures: statements with a name
Procedures are imperative. A procedure body runs statements, can read and write data, and is invoked as a statement of its own with CALL. Define one with CREATE PROCEDURE: it is stored in the catalog next to your data, takes typed parameters, and references them as $param in the body.
Built-in procedures answer to the same naming scheme and call syntax: clock::set and clock::advance steer the engine clock in tests, rql::explain inspects query plans. See Procedures for definitions and Parameters & Control Flow for conditionals and loops inside bodies.
Request-scoped functions
RQL scripts can also define functions on the fly: anonymous closures bound to variables with let, and named functions declared with udf. These are not registered routines - they exist only for the request that defines them. Reach for them to factor a repeated computation inside one script; reach for a procedure when the logic should be stored in the database and callable by name. See Closures & Functions.
