working on adding generics

This commit is contained in:
Andrew Segavac
2022-03-12 04:35:48 -07:00
parent 51c698ba5d
commit 4c1c13149d
10 changed files with 443 additions and 278 deletions

27
examples/generics.bl Normal file
View File

@@ -0,0 +1,27 @@
type MyTrait trait {}
type Pair[K, V: MyTrait] struct {
k: K,
v: V,
}
type Value struct {
value: i64,
}
impl MyTrait for Value {}
impl [K, V: MyTrait] Pair[K, V] {
fn get_value[T](self: Self, a: T): V {
return self.v;
}
}
fn main(): i64 {
let a = Pair{
k: 4,
v: Value{value: 6},
};
return a.get_value(999);
}