From 92bbf45f333bbf9190befc52a6bc114dc2957e41 Mon Sep 17 00:00:00 2001 From: lemon Date: Sun, 7 Aug 2022 15:26:53 +0200 Subject: basic templates (generics) --- bootstrap/test2.cff | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'bootstrap/test2.cff') 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 { + link *Node, + value T, + + fn ok(self Node) void { + } +} + +extern fn main() void { + let n Node = {#null, 0}; + let n Node = {&n, 1}; + + printf("n %d\n", n.value); + printf("n link %d\n", n.link.value); + + let x Node = {}; + n->ok(); + x->ok(); } -- cgit v1.2.3