Skip to main content

Module functions

Module functions 

Source
Expand description

The built-in function registry: ONE table for every function the formula language knows, read by the parser (names, aliases, arity), the compiler (argument and result types, kind), the GUI and CNL (spellings), and the generated function reference (docs/src/functions.md).

Evaluation lives in the engine (improv_engine::builtins); a test there walks all and fails if any evaluable id has no implementation.

A FuncId is persisted in every stored formula, so ids are stable forever: never renumber or reuse one. Aliases resolve to their canonical id at parse time, so stored formulas never hold an alias.

Structs§

FnDef
One built-in function.

Enums§

Arg
An argument’s type.
Category
A function’s documentation category (groups the reference page).
Kind
How a function is compiled.
Over
Which arguments of an aggregation are reduced over the OVER categories.
Ret
What a function returns.

Constants§

INTO
The reserved id of an INTO Category clause: an array function’s trailing argument Call(INTO, [Category(K)]) (SORT(x OVER T INTO K)).
LAMBDA_SLOTS
The highest placeholder id; ids above LAMBDA_SLOTS - 2048 are reserved.
NAMED_LAMBDA_BASE
The first function id of a named LAMBDA call: lambda id is called as FuncId(NAMED_LAMBDA_BASE + id). Above every built-in.
POSITION
POSITION(T): an item’s 1-based position along its category.
WHERE
The reserved id of a WHERE clause: an aggregation’s trailing argument Call(WHERE, [predicate]) (SUM(x OVER T WHERE x > 0)). Not a callable function, so not in the registry.
WINDOW
The reserved id of a window: an aggregation’s trailing argument Call(WINDOW, [from, to]) (SUM(x OVER T[FIRST..THIS])). Each bound is a number (an offset from this item; 0 is THIS) or the text FIRST / LAST.

Statics§

CORE
The P1 core: aggregations, logical, information, math, rounding, text. Order is documentation order within a category.

Functions§

aggregation
The aggregation (or per-item reduction) a name means, if any.
all
Every built-in function.
by_id
The function with id id.
by_name
The functions a name (canonical or alias, case-insensitive) can mean: an aggregation and its scalar twin share a name (SUM(x OVER T) vs SUM(a, b)), so a name maps to at most one of each Kind.
call_at
Where the caret sits in a call: the innermost unclosed NAME( before byte offset caret in text, and the 0-based argument it is in. Strings and nested parentheses are skipped. Signature help uses it.
callable
The non-aggregating function a name means, if any.
closest
Up to n function names closest to word by edit distance (a typo’s likely meaning), nearest first; only those within a third of its length, at least 2.
complete
Function names (canonical and aliases) starting with prefix (case-insensitive), canonical first, for completion.
edit_distance
Levenshtein distance over chars.
is_aggregation
Whether id reduces over OVER categories.
lambda_category
The category standing for parameter i of a named LAMBDA whose body uses the parameter as a category (MAX(x OVER c), POSITION(c)).
lambda_category_of
The parameter index of a category placeholder (see lambda_category).
lambda_param
The reference standing for parameter i in a named LAMBDA’s body.
lambda_param_of
The parameter index of a placeholder id (see lambda_param).
lambda_slot
The placeholder measure id for parameter i (0 the accumulator, 1 the value) of the k-th REDUCE/SCAN lambda in a formula. Placeholders sit at the top of the id space, above any real measure.
lambda_slot_of
The (k, i) of a placeholder id (see lambda_slot).
named_lambda
The function id a call of named LAMBDA id is stored as.
named_lambda_of
The named LAMBDA a function id calls, if it is one.
over
d with its reduced arguments.
reference_markdown
The function reference page (docs/src/functions.md), generated from all so the docs cannot drift from the code. A test compares it with the committed file; UPDATE_DOCS=1 cargo test -p improv_core_model rewrites it.
search
Functions matching query, best first: an exact name or alias, then a prefix, then a word of the name or description. Case-insensitive; an empty query lists everything by name. The help browser’s search and the formula editor’s completion both use this.