Call Expressions
A call expression invokes a function with a list of arguments.
call_expr = expression "(" [ expression { "," expression } ] ")" ;
The number of arguments MUST match the number of parameters in the function signature.
Each argument type MUST be compatible with the corresponding parameter type.
The type of a call expression is the function's return type.
fn add(x: i32, y: i32) -> i32 {
x + y
}
fn main() -> i32 {
add(40, 2) // 42
}
Arguments are evaluated left-to-right before the function is called, as specified in section 4.0.
Call expressions can be nested:
fn add(x: i32, y: i32) -> i32 { x + y }
fn main() -> i32 {
add(add(10, 20), add(5, 7)) // 42
}