In tulip, a function call is expressed as a sequence of expressions, with parentheses appearing freely:
f arg1 (arg2) (g arg3)
If a function receives fewer arguments than its arity, the result is a curried function expecting the remaining arguments. If it receives more, it consumes its arity and calls the return value with the rest. The order of evaluation for a function call is:
- The function expression is evaluated
- Each argument is evaluated
- The call to the function itself is evaluated
- Any remaining calls from returned functions are evaluated
Function calls can be composed in chains. A chain is a sequence of function calls separated by >
:
f arg1 > g arg2 > h arg3
Here, g arg2
is applied to the result of f arg1
, and h arg3
is applied to the result of that. Evaluation order of chains is:
- The first function call is evaluated
- For each remaining element of the chain,
- Evaluate the function call
- Apply the result to the previous value
A command is a special kind of function that takes zero arguments. It is called with a !
, as in my-command!
. Calling a command with arguments results in a panic.