about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-17 18:04:25 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-17 18:04:25 -0700
commit088b57753fe93415b13fe06b3b398033e4ab937d (patch)
treee0119e7ac22265fc5c954d8615f7ed5a6f3cc2db
parentac0e9db526dc15cf91f4c45c4586ddcc19e9708c (diff)
downloadmu-088b57753fe93415b13fe06b3b398033e4ab937d.tar.gz
1393
-rw-r--r--callcc.mu18
1 files changed, 18 insertions, 0 deletions
diff --git a/callcc.mu b/callcc.mu
new file mode 100644
index 00000000..c9edfa47
--- /dev/null
+++ b/callcc.mu
@@ -0,0 +1,18 @@
+# example program: saving and reusing call-stacks or continuations
+
+recipe main [
+#?   $start-tracing #? 1
+  c:continuation <- f
+  continue-from c:continuation            # <-- ..when you hit this
+]
+
+recipe f [
+  c:continuation <- g
+  reply c:continuation
+]
+
+recipe g [
+  c:continuation <- current-continuation  # <-- loop back to here
+  $print 1:literal
+  reply c:continuation
+]