Propagate polymorphic to lambda

This commit is contained in:
Krzosa Karol
2023-04-01 12:16:38 +02:00
parent 21c9a57d96
commit 96d87390bc
3 changed files with 34 additions and 20 deletions

View File

@@ -26,8 +26,12 @@ Array :: struct($T: Type)
Tuple :: struct($A: Type, $B: Type)
a: A
b: B
Triple :: struct($A: Type, $B: Type, $C: Type)
a: A
b: B
c: C
make_array :: (a: *int, count: int): Array(int)
MakeArray :: (a: *int, count: int): Array(int)
result := Array(int) {
data = a,
len = count,
@@ -39,9 +43,13 @@ make_array :: (a: *int, count: int): Array(int)
// @todo: maybe disallow multiple arguments in current form
// and use polimorphism. Then we could make var unpacking,
// unpack structs making it more powerful
multiple_args :: (): Tuple(int, F32)
MultipleArgs :: (): Tuple(int, F32)
return {32, 32}
PolyLambda :: (value: $T): T
pass
main :: (argc: int, argv: **char): int
buff: *int
array: Array(int) = {len = 10, cap = 10, data = buff}
@@ -50,6 +58,7 @@ main :: (argc: int, argv: **char): int
fourth: Array(F32)
fifth: Array(F32)
a,b := multiple_args()
// a,b := MultipleArgs()
a := MultipleArgs()
return 0