evaluate_closed_function
Stable function · Expressions
Tier: stable · Kind: function · Topic: Expressions
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
evaluate_closed_function | not exported | not exported | evaluate_closed_function | EvaluateClosedFunction |
Julia
evaluate_closed_function(name::String, args::AbstractVector)
evaluate_closed_function(name::String, args::Vector) -> Any
Dispatch a closed function call. name is the dotted-module spec name
(e.g. "datetime.julian_day"); args is a vector of evaluated argument
values. Integer-typed results are returned as Int32 to make the integer
contract explicit to callers; float-typed results are Float64.
This entry point PINS its float-typed results to Float64 (it infers as the
concrete Union{Float64,Int32}, which the tree-walk RHS depends on for its
zero-allocation property). Most of the registry tolerates an AD dual argument
anyway, because the answer does not depend on the dual part:
datetime.year…datetime.is_leap_year— piecewise constant in their argument, so they take the dual’s primal (see_value) and returnInt32.interp.searchsorted— the query may be a dual; the result is a discreteInt32index that carries no derivative.
The three float-RETURNING functions (interp.linear, interp.bilinear,
datetime.julian_day) cannot honour the Float64 pin on a dual, so they throw
here. Differentiating call sites use evaluate_closed_function_ad
instead, which is the same registry without the pin.
For interp.searchsorted the second argument must be the table (a
Vector{<:Real}) — the caller is responsible for extracting the array
from a const-op AST node before invoking this function.
Throws ClosedFunctionError
on contract violations.
TypeScript
TypeScript does not export this function.
Python
Python does not export this function.
Rust
pub fn evaluate_closed_function(name: &str, args: &[ClosedArg]) -> Result<ClosedValue, ClosedFunctionError>
Dispatch a closed function call. name is the dotted-module spec path
(e.g. "datetime.julian_day"); args is the list of evaluated argument
values. Returns ClosedValue
so callers can preserve the integer/float
distinction; promotion to f64 is available via ClosedValue::as_f64.
Go
func EvaluateClosedFunction(name string, args []any) (any, error)
EvaluateClosedFunction dispatches a closed function call. name is the dotted-module spec name (e.g. “datetime.julian_day”); args is a slice of evaluated argument values. Integer-typed results are returned as int32 to make the integer contract explicit; float-typed results are float64. For interp.searchsorted, the second argument MUST be the inline table extracted from the const-op AST node — the caller is responsible for that extraction.
Returns *ClosedFunctionError on contract violations.