From 1b0ba4e7c863526e5d144d338aa544f6e32bce87 Mon Sep 17 00:00:00 2001 From: Alexander Nutz Date: Fri, 12 Sep 2025 10:25:39 +0200 Subject: [PATCH] v0.0.4: automatic return types and templated generics --- spec.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/spec.md b/spec.md index 45ff57c..18cad58 100644 --- a/spec.md +++ b/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