Language Reference
Functions, Calls, and Function Values
Function declarations, explicit multi-argument calls, the single-argument bare-call form, and first-class function values.
Function declaration
function add(left: i64, right: i64) -> i64 {
return left + right;
}
let answer = add(20, 22);
Function declarations define a name, typed parameters, a return type, and a body. Standard calls use parentheses and commas for arguments.
Call syntax
The current parser accepts a compact bare-call form when a single argument is supplied:
use std.io;
print("parentheses-call");
print "bare-call";
This shorthand is intentionally narrow. Multiple arguments should use parenthesized syntax:
let value = add(20, 22);
let value = add 20, 22;. The bare form should not be
generalized into an ambiguous multi-argument grammar.
Function values are not automatic calls
A function name used as a value refers to that function; it does not invoke it automatically. This supports callback-style use while keeping the call site explicit.
function meaning() -> i64 {
return 42;
}
let value = meaning;
let answer = value();
let direct = meaning();
Here, value holds a function value. Both
value() and meaning() explicitly call a
function; meaning without parentheses does not.
Current limitations
-
The function-value type form is represented as
Fn(Args)->Return, but capture and closure semantics are not defined. - A bare name does not implicitly invoke the referenced function.
- The accepted argument grammar for bare calls should remain documented as a specific shorthand rather than a general replacement for call parentheses.