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:
.myfunction
The 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 .from
When 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 .from
As 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 .from
Parameters
name of the function
- Likely a body argument
content of the function. Function parameters must be explicit lambda parameters