aboutsummaryrefslogtreecommitdiff
path: root/std/prelude/arrays.pk
diff options
context:
space:
mode:
Diffstat (limited to 'std/prelude/arrays.pk')
-rw-r--r--std/prelude/arrays.pk20
1 files changed, 20 insertions, 0 deletions
diff --git a/std/prelude/arrays.pk b/std/prelude/arrays.pk
new file mode 100644
index 0000000..2e4a4d4
--- /dev/null
+++ b/std/prelude/arrays.pk
@@ -0,0 +1,20 @@
+## std.arrays: The array[T, S] primitive and associated functions.
+## A stub module for documentation. Mostly compiler magic.
+
+## Primitive fixed-size arrays. Their size is statically known at compile-time.
+pub type array[T, S: static[uint]]
+
+## Array access. Returns None if i is out of range.
+pub func get[T, S: static[uint]](self: array[T, S], i: uint): T?
+## Array mutation.
+# todo: how do we detect range errors?
+pub func set[T, S: static[uint]](self: mut array[T, S], i: uint, val: T): T?
+## A helper function to get the length of an array.
+## Known to the compiler, and computed at compile-time.
+pub func len[T, S: static[uint]](self: array[T, S], i: uint): T?
+
+type ArrayIter[T, S: static[uint]] = struct
+ ...
+pub func iter[T, S: static[uint]](self: array[T, S]): ArrayIter[T, S]
+
+# todo: Eq, PartialEq, Ord, PartialOrd