v0.0.4: automatic return types and templated generics
This commit is contained in:
20
spec.md
20
spec.md
@@ -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
|
||||
|
Reference in New Issue
Block a user