shithub: mc

Download patch

ref: 0f342c47db402a0b4ba021dab79414941180c1f0
parent: 26fef326df126ced69c6eb4f531b487de37e23c7
author: Ori Bernstein <[email protected]>
date: Wed Jan 15 05:45:38 EST 2014

Add 'mk()' function to libstd.

--- a/6/simp.c
+++ b/6/simp.c
@@ -1432,7 +1432,6 @@
                 fatal(n->line, "trying to continue when not in loop");
             jmp(s, s->loopstep[s->nloopstep - 1]);
             break;
-            break;
         default:
             if (istyfloat(exprtype(n))) {
                 switch (exprop(n)) {
--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -17,6 +17,7 @@
     htab.myr \
     intparse.myr \
     ipparse.myr \
+    mk.myr \
     now.myr \
     option.myr \
     optparse.myr \
--- /dev/null
+++ b/libstd/mk.myr
@@ -1,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
+}