summaryrefslogtreecommitdiff
path: root/tnslc/tests/complex/generics.tnsl
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2023-02-16 05:14:31 -0500
committerKyle Gunger <kgunger12@gmail.com>2023-02-16 05:14:31 -0500
commit09df1bb48823631228af3df647111af1eebc854b (patch)
treeef091fc942b00b224f7d66aacb0c3db0ab4d490c /tnslc/tests/complex/generics.tnsl
parentc94edbe007910755087e71cbb1a6a349d75e9b85 (diff)
Collapse tnslc into a single file
Diffstat (limited to 'tnslc/tests/complex/generics.tnsl')
-rw-r--r--tnslc/tests/complex/generics.tnsl35
1 files changed, 35 insertions, 0 deletions
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