tweak wrapper for delimcc
[lambda.git] / topics / week13_native_continuation_operators.mdwn
index ce68d11..179b780 100644 (file)
@@ -105,7 +105,9 @@ However, OCaml doesn't have any continuation operators in its standard deploymen
     # #load "delimcc.cma";;
     # let reset_label = ref None;;
     # let reset body = let p = Delimcc.new_prompt () in
-      reset_label := Some p; let res = Delimcc.push_prompt p body in reset_label := None; res;;
+      let oldp = !reset_label in
+      reset_label := Some p; let res = Delimcc.push_prompt p body in
+      reset_label := oldp; res;;
     # let shift fun_k = match !reset_label with
       | None -> failwith "shift must be inside reset"
       | Some p -> Delimcc.shift p fun_k;;
@@ -146,7 +148,7 @@ Here are some examples of using these different continuation operators. The cont
 3.  <pre><b>let p = </b>let/cc k (1,k) <b>in
     let y = snd p (2, ident) in
     (fst p, y)</b></pre>
-    In the first line, we bind the continuation function (the bold code) to `k` and then bind the pair of `1` and that function to the variable `p`.
+    In the first line, we bind the continuation function (the bold code) to `k` and then bind the variable `p` to the pair of `1` and that function.
     In the second line, we extract the continuation function from the pair `p` and apply it to the argument `(2, ident)`. That results in the following code being run:
     <pre><b>let p = </b>(2, ident) <b>in
     let y = snd p (2, ident) in