/** * Function Registry — Declarative function descriptors and native implementations. * * Each function is described by a `FunctionDescriptor` that carries metadata * about arity and the implementation itself. The evaluator uses this metadata * to validate arguments and invoke functions. * * Special forms (IF, LET, LAMBDA, etc.) are NOT registered here — they * are handled directly by the evaluator's special-form dispatch. */ import type { RuntimeValue } from "./values.js"; /** * A function descriptor with metadata and implementation. */ export interface FunctionDescriptor { /** Canonical uppercase name. */ readonly name: string; /** Minimum number of arguments. */ readonly minArity: number; /** Maximum number of arguments. Infinity for variadic. */ readonly maxArity: number; /** * The function implementation. * Receives eagerly evaluated arguments as `RuntimeValue[]`. * Returns a `RuntimeValue`. */ readonly invoke: (args: RuntimeValue[]) => RuntimeValue; } /** * Register a function descriptor. The descriptor is stored under its * canonical (unprefixed) name only — `_XLFN.` / `_XLFN._XLWS.` prefix * variants are resolved dynamically in `lookupFunction`. This keeps the * registry small and avoids triple-entry bookkeeping for 200+ functions. */ export declare function registerFunction(desc: FunctionDescriptor): void; /** * Look up a function by uppercase name. Accepts `_XLFN.` and * `_XLFN._XLWS.` prefixed variants by stripping the prefix before lookup * (a no-op for plain names, so plain lookups also go through a single * Map.get call — avoiding the double-lookup pattern used previously). * * Fast-path: the overwhelming majority of lookups use plain names * (`SUM`, `IF`, `VLOOKUP`, …). Checking the prefix sentinel byte up * front lets those callers skip the `slice`/`startsWith` machinery in * `stripFunctionPrefix` entirely. */ export declare function lookupFunction(name: string): FunctionDescriptor | undefined; /** * Convenience: define and register an eager function. */ export declare function defineEager(name: string, minArity: number, maxArity: number, invoke: (args: RuntimeValue[]) => RuntimeValue): FunctionDescriptor; export declare function ensureRegistryInitialized(): void;