From 09df1bb48823631228af3df647111af1eebc854b Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Thu, 16 Feb 2023 05:14:31 -0500 Subject: Collapse tnslc into a single file --- tnslc/tests/complex/generics.tnsl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tnslc/tests/complex/generics.tnsl (limited to 'tnslc/tests/complex/generics.tnsl') diff --git a/tnslc/tests/complex/generics.tnsl b/tnslc/tests/complex/generics.tnsl new file mode 100644 index 0000000..3f62474 --- /dev/null +++ b/tnslc/tests/complex/generics.tnsl @@ -0,0 +1,35 @@ +struct ListNode (type T) { + T element, + ~ListNode(T) next +} + +/; method ListNode + /; get_el [T] + return self.element + ;/ + + /; get_next [ListNode(T)] + return self.next` + ;/ +;/ + +struct ReferenceNode (type T) extends ListNode(T`) { + super +} + +/; method ReferenceNode + /; change_ref (~T new_ref) + ~self.element = new_ref + ;/ +;/ + +struct List(type T) { + +} + +# Generic (type T) +# Unknown generic (?) +# Ref to a type (type T) -> T` +# Ref types can be used interchangably with their referenced type while pointer types can not +# Variables typed by reference have the additional trait that you can +# set the address of that variable \ No newline at end of file -- cgit v1.2.3