added arrow syntax for forcing output types and added the "any" type (which is basically useless and will likely change in the future)

This commit is contained in:
mark
2023-06-04 21:33:35 +02:00
parent efe8a177dc
commit db0be51fa4
11 changed files with 142 additions and 54 deletions

View File

@@ -1,8 +1,23 @@
# mers statements overview
# Mers statements overview
This is the documentation for mers statements.
In code, statements are represented by `SStatement`, `SStatementEnum`, `RStatement`, and `RStatementEnum`.
## statement prefixes
A statement can be prefixed with any number of stars `*`. This is called dereferencing and turns a reference to a value into the value itself. Modifying the value after a dereference leaves the value the reference was pointing to untouched (the data will be cloned to achieve this).
A statement can also be prefixed with an arrow followed by the type the statement will have: `-> int/float 12`.
Although the statement will always return an `int`, mers will assume that it could also return a float.
If the statement's output doesn't fit in the forced type (`-> int "text"`), mers will generate an error.
In combination with functions, this is similar to rust's syntax:
fn my_func(a int, b int) -> int {
a + b
}
# Different statements
## Value
A statement that always returns a certain value: `10`, `"Hello, World"`, ...