aboutsummaryrefslogtreecommitdiff
path: root/std/prelude/clone.pk
diff options
context:
space:
mode:
Diffstat (limited to 'std/prelude/clone.pk')
-rw-r--r--std/prelude/clone.pk28
1 files changed, 28 insertions, 0 deletions
diff --git a/std/prelude/clone.pk b/std/prelude/clone.pk
new file mode 100644
index 0000000..5b16b8b
--- /dev/null
+++ b/std/prelude/clone.pk
@@ -0,0 +1,28 @@
+## std.clone: Interfaces for explicitly Clonable types.
+## This module is imported by default.
+
+## The Clone interface. Any type implementing Clone is cloneable.
+## Data structures built with pointers and references are pretty much
+## the only things that are *not* implicitly clonable.
+pub type Clone = interface
+ clone(lent Self): Self # todo
+
+## Generic implementation of `clone` for structs.
+pub func clone[T: struct](self: T): T =
+ ...
+
+## Generic implementation of `clone` for tuples.
+pub func clone[T: tuple](self: T): T =
+ ...
+
+## Implementation of `clone` for arrays of any size.
+pub func clone[T, S: static[uint]](self: array[T, S]): array[T, S] =
+ ...
+
+## Implementation of `clone` for lists.
+pub func clone[T](self: list[T]): list[T] =
+ ...
+
+## Implementation of `clone` for strings.
+pub func clone(self: str): str =
+ ...