+
+What would a "snapshot of the code outside the box" look like? Well, let's rearrange the code somewhat. It should be equivalent to this:
+
+ let x = 2 in
+ let foo_result =
+ +---try begin----------------+
+ | (if x = 1 then 10 |
+ | else abort 20) + 100 |
+ +---end----------------------+
+ in (foo_result) + 1000;;
+
+and we can think of the code starting with `let foo_result = ...` as a function, with the box being its parameter, like this:
+
+ fun box ->
+ let foo_result = box
+ in (foo_result) + 1000
+
+That function is our "snapshot". Normally what happens is that code *inside* the box delivers up a value, and that value gets supplied as an argument to the snapshot-function just described. That is, our code is essentially working like this:
+
+ let x = 2
+ in let snapshot = fun box ->
+ let foo_result = box
+ in (foo_result) + 1000
+ in let value =
+ (if x = 1 then 10
+ else ... (* we'll come back to this part *)
+ ) + 100
+ in shapshot value;;
+
+But now how should the `abort 20` part, that we ellided here, work? What should happen when we try to evaluate that?
+
+Well, that's when we use the snapshot code in an unusual way. If we encounter an `abort 20`, we should abandon the code we're currently executing, and instead just supply `20` to the snapshot we saved when we entered the box. That is, something like this:
+
+ let x = 2
+ in let snapshot = fun box ->
+ let foo_result = box
+ in (foo_result) + 1000
+ in let value =
+ (if x = 1 then 10
+ else snapshot 20
+ ) + 100
+ in shapshot value;;
+
+Except that isn't quite right, yet---in this fragment, after the snapshot code is finished, we'd pick up again inside `let value = (...) + 100 in snapshot value`. We don't want to pick up again there. We want instead to do this:
+
+ let x = 2
+ in let snapshot = fun box ->
+ let foo_result = box
+ in (foo_result) + 1000
+ in let value =
+ (if x = 1 then 10
+ else snapshot 20 THEN STOP
+ ) + 100
+ in shapshot value;;
+
+We can get that by some further rearranging of the code:
+
+ let x = 2
+ in let snapshot = fun box ->
+ let foo_result = box
+ in (foo_result) + 1000
+ in let finish_value = fun start ->
+ let value = start + 100
+ in snapshot value
+ in
+ if x = 1 then finish_value 10
+ else snapshot 20;;
+
+And this is indeed what is happening, at a fundamental level, when you use an expression like `abort 20`.
+