1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-28 00:59:31 +00:00

[doc] standard library documentation first draft

This commit is contained in:
Étienne Fildadut 2024-06-01 13:52:58 +02:00
parent 41dede808e
commit 0195913dcc
29 changed files with 2045 additions and 67 deletions

View file

@ -243,6 +243,20 @@ There are three ways to associate an argument to a function parameter:
* positional arguments: the i-th argument in the argument list is associated with the i-th parameter in the function definition parameter list;
* the assignment argument is always associated with the assignment parameter.
If the function only takes a single tuple or struct as an argument, the parentheses can be omitted.
```
:$fn(x)
fn[1,2,3]
// is the same as
fn([1,2,3])
fn{1:2,3}
// is the same as
fn({1:2,3})
```
##### Dynamic dispatch
Anselme uses [dynamic dispatch](https://en.wikipedia.org/wiki/Dynamic_dispatch), meaning it determine which function should be called at run-time. The dispatch is performed using all of the function parameters.
@ -776,6 +790,12 @@ For these forms, the parameters can optionally be wrapped in parentheses in case
:$(a::is number).b
```
### Environments
Environments consist of a scope, and can be used to get, set, and define variable in a scope that isn't the current one.
An environment can, for example, be obtained using `load(path)`, which returns the exported scope of the file `path`.
### Overloads
Overloads consist of a list of arbitrary values. Each value should be [callable](#calling_callables).