🐐 First order functions

This commit is contained in:
2026-04-21 18:12:15 +02:00
parent db5b7bf144
commit 693054491f
18 changed files with 407 additions and 46 deletions

View File

@@ -244,6 +244,28 @@ Calling a function is done with the `INVOCA` keyword.
> CXXI
```
## First-class functions
Functions are first-class values in CENTVRION. They can be assigned to variables, passed as arguments, returned from functions, and stored in arrays or dicts.
Anonymous functions are created with the `FVNCTIO` keyword:
![FVNCTIO](snippets/fvnctio.png)
```
> XIV
```
`INVOCA` accepts any expression as the callee, not just a name:
![INVOCA expressions](snippets/invoca_expr.png)
```
> VI
> VI
> XVI
```
Note: CENTVRION does **not** have closures. When a function is called, it receives a copy of the *caller's* scope, not the scope where it was defined. Variables from a function's definition site are only available if they also exist in the caller's scope at call time.
## Built-ins
### DICE
`DICE(value, ...)`