summaryrefslogtreecommitdiff
path: root/lib/std/mk.myr
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/mk.myr')
-rw-r--r--lib/std/mk.myr22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/std/mk.myr b/lib/std/mk.myr
new file mode 100644
index 0000000..19b46d2
--- /dev/null
+++ b/lib/std/mk.myr
@@ -0,0 +1,22 @@
+use "alloc.use"
+
+pkg std =
+ generic mk : (val : @a -> @a#)
+;;
+
+/* Takes a value, and heapifies it.
+
+FIXME: This depends on inlining and copy propagation
+in order to be efficient. Neither of those are
+currently implemented. That means that this function
+is not efficient.
+
+It's still damn convenient, though, so it's in.
+*/
+generic mk = {val
+ var p
+
+ p = alloc()
+ p# = val
+ -> p
+}