Overview of Functions¶
A function declaration names its call parameters, optional return type, and body:
::clamp FUNCTION(@value I32, @minimum I32, @maximum I32): I32
{
IF (value < minimum)
{
RETURN minimum;
}
IF (value > maximum)
{
RETURN maximum;
}
RETURN value;
}
::offset FUNCTION(@ARG:value I32, @amount:delta I32): I32
{
RETURN value + delta;
}
Parameter forms¶
@name Typedeclares a named parameter.@api_name:local_name Typeseparates the call-site name from the body name.%name Typedeclares a positional parameter.%IGNORED Typeaccepts one unused positional value without declaring a local name.%...name Typedeclares a positional variadic pack.%...IGNORED Typeaccepts an unused positional pack.
Named parameters are the primary form for ordinary APIs because each call states which value serves each purpose. Positional parameters remain useful when position is intrinsic to the API, especially variadic packs. Named and positional parameters may appear in one signature; the corresponding call must use explicit argument groups.
Return types¶
The return type follows the parameter list:
Omitting the return type declares a VOID function:
AUTO may be used as a deduced return type. Every reached return path must
produce a compatible result.
Member-function receiver qualifiers are covered on Structs and members.
Capturing keyword arguments¶
A final @KWARGS ... parameter collects unmatched named arguments into a
composite. The APPLY form passes that
record to another callable. COMPOSITE_* reflection inspects optional fields.
Reference¶
See the Functions Reference for the complete language rules, constraints, and technical edge cases.