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
OVERcategories. - Ret
- What a function returns.
Constants§
- INTO
- The reserved id of an
INTO Categoryclause: an array function’s trailing argumentCall(INTO, [Category(K)])(SORT(x OVER T INTO K)). - LAMBDA_
SLOTS - The highest placeholder id; ids above
LAMBDA_SLOTS - 2048are reserved. - NAMED_
LAMBDA_ BASE - The first function id of a named LAMBDA call: lambda
idis called asFuncId(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
WHEREclause: an aggregation’s trailing argumentCall(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;0is THIS) or the textFIRST/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)vsSUM(a, b)), so a name maps to at most one of eachKind. - call_at
- Where the caret sits in a call: the innermost unclosed
NAME(before byte offsetcaretintext, 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
nfunction names closest towordby 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
idreduces overOVERcategories. - lambda_
category - The category standing for parameter
iof 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
iin 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 thek-thREDUCE/SCANlambda 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 (seelambda_slot). - named_
lambda - The function id a call of named LAMBDA
idis stored as. - named_
lambda_ of - The named LAMBDA a function id calls, if it is one.
- over
dwith its reduced arguments.- reference_
markdown - The function reference page (
docs/src/functions.md), generated fromallso the docs cannot drift from the code. A test compares it with the committed file;UPDATE_DOCS=1 cargo test -p improv_core_modelrewrites 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.