aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2024-04-13 15:46:22 +0100
committerJuan J. Martinez <jjm@usebox.net>2024-04-13 15:46:29 +0100
commit83b150097303ee7c8c9913b35cf863c7db955a86 (patch)
tree35e020990b8b67c9f8d7324af3c4dbe2dc4c24d5
parent1252cc77514e8c485396680827bf52c517be7cdd (diff)
downloadmicro-lang-hs-83b150097303ee7c8c9913b35cf863c7db955a86.tar.gz
micro-lang-hs-83b150097303ee7c8c9913b35cf863c7db955a86.zip
Typos, clarificationsHEADmain
-rw-r--r--language.md16
1 files changed, 9 insertions, 7 deletions
diff --git a/language.md b/language.md
index 63b2b1d..0957480 100644
--- a/language.md
+++ b/language.md
@@ -151,7 +151,7 @@ Logic operators result on a boolean type.
| Type | Description | Samples |
| --- | --- | --- |
-| ([parameters]) -> [return] | function | `(a: u8) -> u8 { return a + 1; }` |
+| ([parameters]) -> [return] | function | `(a: u8): u8 { return a + 1; }` |
| ([parameters]) | function (no return value) | `() { return; }` |
Functions can be declared with `def` when they have a name, or as anonymous using the lambda syntax.
@@ -176,7 +176,7 @@ Anonymous function:
Function are higher order functions:
```
-def apply(fn: (u8) -> u8, a: u8, b: u8): u8 {
+def apply(fn: (u8): u8, a: u8, b: u8): u8 {
return fn(a, b);
}
@@ -189,7 +189,7 @@ apply((a: u8, b: u8): u8 {
2, 8); # 10
# lambdas can be assigned to variables
-var double: (u8) -> u8 = (a: u8): u8 {
+var double: (u8): u8 = (a: u8): u8 {
return a + a;
};
@@ -198,7 +198,7 @@ double(10); # 20
Anonymous functions can only access local variables (closures aren't supported):
```
-def closure(a: u8): () -> u8 {
+def closure(a: u8): (): u8 {
return (): u8 {
return a; # invalid return, undefined a
};
@@ -229,7 +229,7 @@ Using a *nil* reference will result in a runtime error.
```
# fn doesn't hold a reference
-var fn: (u8) -> u8 = nil;
+var fn: (u8): u8 = nil;
fn(10); # runtime error
```
@@ -250,7 +250,7 @@ def A {
var (
n: u8 = 100,
m: bool = false,
- dec: (u8) -> u8 = nil
+ dec: (u8): u8 = nil
);
# it is possible to define functions local
@@ -289,6 +289,8 @@ var c: A = nil;
Recursive structures are not supported and local structures can't be used as return value in a function.
+XXX: how do we implement e.g. linked lists?
+
### Arrays
Arrays are zero based and are supported for all types.
@@ -346,7 +348,7 @@ Built-in functions:
| Function | Description | Samples |
| --- | --- | --- |
| len | get the length of an array as u16 | `len(arr); # 5` |
-| incbin | load a binary file as []u8 | `const f: []u8 = incbin("file.bin");` |
+| incbin | include a binary file as []u8 | `const f: []u8 = incbin("file.bin");` |
### Strings