Merge branch 'working'
[lambda.git] / topics / _cps_and_continuation_operators.mdwn
index 72b0034..679f0fb 100644 (file)
@@ -175,6 +175,8 @@ So too will examples. We'll give some examples, and show you how to try them out
 
        <!-- GOTCHAS?? -->
 
+-- cutting for control operators --
+
 3.     `callcc` was originally introduced in Scheme. There it's written `call/cc` and is an abbreviation of `call-with-current-continuation`. Instead of the somewhat bulky form:
 
                (call/cc (lambda (k) ...))
@@ -211,6 +213,8 @@ What happens here? First, we capture the continuation where `p` is about to be a
 
        '(2 2 . #<procedure>)
 
+-- end of cut --
+
 Ok, so now let's see how to perform these same computations via CPS.
 
 In the lambda evaluator:
@@ -276,6 +280,8 @@ The third example is more difficult to make work with the monadic library, becau
 
 <!-- FIXME -->
 
+-- cutting following section for control operators --
+
 Some callcc/letcc exercises
 ---------------------------
 
@@ -464,6 +470,10 @@ The box is working like a reset. The `abort` is implemented with a `shift`. Earl
 
 `snapshot` here corresponds to the code outside the `reset`. `continue_normally` is the middle block of code, between the `shift` and its surrounding `reset`. This is what gets bound to the `k` in our `shift`. The `if...` statement is inside a `shift`. Notice there that we invoke the bound continuation to "continue normally". We just invoke the outer continuation, saved in `snapshot` when we placed the `reset`, to skip the "continue normally" code and immediately abort to outside the box.
 
+
+-- end of cut --
+
+
 Using `shift` and `reset` operators in OCaml, this would look like this:
 
        #require "delimcc";;
@@ -515,6 +525,8 @@ In collecting these CPS transforms and implementing the monadic versions, we've
 *      Sabry, "Note on axiomatizing the semantics of control operators" (1996)
 
 
+-- cutting some of the following for control operators --
+
 Examples of shift/reset/abort
 -----------------------------