🐐 TEMPTA/CAPE
This commit is contained in:
18
README.md
18
README.md
@@ -240,6 +240,24 @@ condition. Exit the loop with `ERVMPE` (or `REDI` from inside a function).
|
||||
> V
|
||||
```
|
||||
|
||||
## Error handling
|
||||
|
||||
Errors can be caught using `TEMPTA` (temptare = to try) and `CAPE` (capere = to catch). The `CAPE` block binds the error message to a variable as a string.
|
||||
|
||||
```
|
||||
TEMPTA {
|
||||
DESIGNA x VT I / NVLLVS
|
||||
} CAPE error {
|
||||
DICE(error)
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
> Division by zero
|
||||
```
|
||||
|
||||
If the try block succeeds, the catch block is skipped. If an error occurs in the catch block, it propagates up. `TEMPTA`/`CAPE` blocks can be nested.
|
||||
|
||||
## Functions
|
||||
Functions are defined with the `DEFINI` and `VT` keywords. The `REDI` keyword is used to return. `REDI` can also be used to end the program, if used outside of a function.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user