6. Function Calls #
6.1 Named Arguments Requirement #
CRITICAL RULE: Functions with more than one parameter MUST be called with named arguments.
Valid Function Calls #
// Single parameter - positional allowed
fn double(x) = x * 2
let result = double(5)
// Zero parameters - no arguments
fn getValue() = 42
let value = getValue()
// Multiple parameters - named arguments required
fn add(x, y) = x + y
let sum = add(x: 10, y: 20)
// Multiple parameters - order doesn't matter with named args
let sum2 = add(y: 20, x: 10)
Invalid Function Calls #
// ERROR: Multi-parameter function with positional arguments
fn add(x, y) = x + y
let sum = add(10, 20) // ❌ Compilation error
// ERROR: Mixed positional and named arguments
let sum = add(10, y: 20) // ❌ Compilation error
6.2 Function Call Compilation Rules #
- Single Parameter Functions: May use positional arguments
- Zero Parameter Functions: Called with empty parentheses
()
- Multi-Parameter Functions: Must use named arguments for ALL parameters
- Argument Reordering: Named arguments are reordered to match parameter declaration order