v0.0.4: automatic return types and templated generics

This commit is contained in:
2025-09-12 10:25:39 +02:00
parent 5d447cb520
commit 1b0ba4e7c8

20
spec.md
View File

@@ -51,7 +51,7 @@ value := 2 # `:=` mutates the cell
print(Num.to_str(!value))
```
## (Almost) no function or operator overloading
## no confusing function or operator overloading
all operators:
- `Num + Num` (has overloads for fixed width number types)
- `Num - Num` (has overloads for fixed width number types)
@@ -132,6 +132,24 @@ def example6-error(): Option[Unit] {
}
```
## automatic return types
```
def add(a: Num, b: Num) -> _ {
a + b
}
```
## templated generics
```
def [a,b] add(a: a, b: b) -> _ {
a + b
}
add(1,2)
add(1,"2") # error: in template expansion of add[Num,List[Char]]: No definition for `Num + List[Char]`
```
## pattern matching
```
type Option[t] = 'None | 'Some t