aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/test2.cff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-07 15:26:53 +0200
committerlemon <lsof@mailbox.org>2022-08-07 15:29:04 +0200
commit92bbf45f333bbf9190befc52a6bc114dc2957e41 (patch)
tree87196fb07a02e1eb6cb5048da86dadd30a69ddc1 /bootstrap/test2.cff
parent0a4f81e86d21d056329a2b7b2186152e9b9c2375 (diff)
basic templates (generics)
Diffstat (limited to 'bootstrap/test2.cff')
-rw-r--r--bootstrap/test2.cff21
1 files changed, 18 insertions, 3 deletions
diff --git a/bootstrap/test2.cff b/bootstrap/test2.cff
index ee24d45..66603ba 100644
--- a/bootstrap/test2.cff
+++ b/bootstrap/test2.cff
@@ -1,6 +1,21 @@
import "libc.hff";
-struct Node {
- next *Node,
- value int,
+struct Node<T> {
+ link *Node,
+ value T,
+
+ fn ok(self Node) void {
+ }
+}
+
+extern fn main() void {
+ let n Node<int> = {#null, 0};
+ let n Node<int> = {&n, 1};
+
+ printf("n %d\n", n.value);
+ printf("n link %d\n", n.link.value);
+
+ let x Node<f32> = {};
+ n->ok();
+ x->ok();
}