summaryrefslogtreecommitdiff
path: root/tnslc/tests/complex/generics.tnsl
diff options
context:
space:
mode:
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