Constant polymorphic names

This commit is contained in:
gingerBill
2018-09-10 14:21:19 +01:00
parent 4c4de1d6c4
commit 46b1868185
2 changed files with 46 additions and 5 deletions
+17 -1
View File
@@ -489,6 +489,23 @@ parametric_polymorphism :: proc() {
r = Error.Foo0;
fmt.println(r);
}
{ // Polymorphic names
foo :: proc($N: $I, $T: typeid) -> (res: [N]T) {
fmt.printf("Generating an array of type %v from the value %v of type %v\n",
typeid_of(type_of(res)), N, typeid_of(I));
for i in 0..N-1 {
res[i] = i*i;
}
return;
}
T :: int;
array := foo(4, T);
for v, i in array {
assert(v == T(i*i));
}
}
}
@@ -794,7 +811,6 @@ diverging_procedures :: proc() {
foo();
}
main :: proc() {
when true {
general_stuff();