Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompiledFunc ¶
type CompiledFunc struct {
// contains filtered or unexported fields
}
CompiledFunc is a Function paired with its parameter signature precomputed once at registration. Argument resolution reads the cached signature instead of recomputing it, so nothing about the (static) parameter list is derived per call.
func (*CompiledFunc) Name ¶
func (c *CompiledFunc) Name() string
func (*CompiledFunc) Params ¶
func (c *CompiledFunc) Params() []Parameter
func (*CompiledFunc) Resolve ¶
func (c *CompiledFunc) Resolve( positional []core.Value, named map[string]core.Value, ) (map[string]core.Value, error)
Resolve binds evaluated call arguments to the function's parameters and returns them keyed by parameter name.
Binding is strict (Python keyword-only style): positional arguments fill positional parameters by position, named arguments fill named parameters by name. A positional parameter cannot be supplied by name, and a named parameter cannot be supplied positionally.
type Function ¶
type Function interface {
// Returns the function name as it appears in source code.
Name() string
// Returns the ordered list of parameter descriptors.
// Order matters for positional argument binding.
Params() []Parameter
// Call executes the function with fully-resolved, validated arguments.
// args is keyed by parameter name and always contains every parameter
// (required args + provided optional args + defaults).
Call(args map[string]core.Value) (core.Value, error)
}
Function is the interface every built-in function must implement.
Lifecycle during a call:
- Interpreter evaluates all argument expressions -> positional []Value + named map[string]Value
- CompiledFunc.Resolve validates and maps them to the parameter list -> map[string]Value
- Function.Call receives the resolved map and returns a Value
type Parameter ¶
type Parameter struct {
// Name is the parameter name. For named parameters it is the keyword used
// at the call site: fn(name: value). For positional parameters it is used
// as the key in the resolved argument map.
Name string
// Description documents the parameter for help output and generated docs.
Description string
// Default is the value substituted when a named parameter is omitted.
// Its presence is what makes a parameter named (keyword-only) and optional;
// a nil Default makes the parameter positional and required.
Default core.Value
// AcceptedKinds lists the value kinds this parameter accepts.
// An empty slice means any kind is accepted.
AcceptedKinds []core.ValueKind
}
Describes a single parameter of a built-in function.
Whether a parameter is positional or named is derived from Default, mirroring the Python/PHP model:
- Positional (Default == nil): supplied by position - fn(value) - always required.
- Named (Default != nil): supplied by name - fn(name: value) - always optional, falling back to Default when omitted.
All positional parameters must be declared before any named parameter.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all built-in functions available during program execution. It is built once at startup and shared across all Program.Run calls.
func GetRegistry ¶
func GetRegistry() *Registry