function
Defines a custom function that can be called later in the document.
The function is saved in the current context, and can be shared via mechanisms such as include or subdocuments.
.function {myfunction}
You have called this function!The function can be called normally:
.myfunctionThe amount of parameters is determined by the amount of explicit lambda parameters.
.function {add}
a b:
This function has two parameters, `a` and `b`.Arguments can be accessed as in a function call by name:
.function {greet}
from to:
**Hello .to** from .fromWhen calling the function, argoments can be positional, named, or a mix of both:
.greet {John} {world}.greet from:{John} to:{world}A parameter might also be optional. In this case, if the corresponding argument is not provided, it will be none:
.function {greet}
from to?:
**Hello .to** from .fromAs with any none value, operations defined in the Optionality stdlib module help dealing with it, including simulating default values:
.function {greet}
from to?:
**Hello .to::otherwise {world}** from .fromParameters
name of the function
- Likely a body argument
content of the function. Function parameters must be explicit lambda parameters