-
Notifications
You must be signed in to change notification settings - Fork 0
Function calls
In Append, function calls adopt a more fluid syntax by placing the function name after the first parameter. This approach enhances readability, drawing inspiration from the fluent design and binary operators.
Instead of wrapping arguments in brackets, you simply follow them with the function:
"hello" print
Operator precedence matters. For instance, (1+3) sqr
yields 16. Without parentheses, +
has lower priority than function calls. Likewise, 2*2 sqr
results in 16 since multiplication precedes function calls. Refer to operator precedence for more details.
The backpipe \
allows for chaining function calls seamlessly:
-
4 sqr \ print
will display 16.
When a function requires two parameters, simply append the second parameter:
-
mut myList add 12
: themut
keyword here denotes thatmyList
will be modified.
Append handles asynchronous functions gracefully. By default, they are awaited, ensuring synchronous behavior. However, if you wish to proceed without waiting, use the defer
keyword:
-
"phonebook.txt" readFile defer
will return a promise rather than directly providing the file content.