continue_foo_normally -> continue_foo_snapshot
authorjim <jim@web>
Fri, 1 May 2015 11:22:52 +0000 (07:22 -0400)
committerLinux User <ikiwiki@localhost.members.linode.com>
Fri, 1 May 2015 11:22:52 +0000 (07:22 -0400)
topics/week13_coroutines_exceptions_and_aborts.mdwn

index de7e8c0..a820bde 100644 (file)
@@ -345,11 +345,11 @@ We can get that by some further rearranging of the code:
     in let outer_snapshot = fun box ->
         let foo_result = box
         in (foo_result) + 1000
     in let outer_snapshot = fun box ->
         let foo_result = box
         in (foo_result) + 1000
-    in let continue_foo_normally = fun from_value ->
+    in let continue_foo_snapshot = fun from_value ->
         let value = from_value + 100
         in outer_snapshot value
     in (* start of foo_applied_to_x *)
         let value = from_value + 100
         in outer_snapshot value
     in (* start of foo_applied_to_x *)
-        if x = 1 then continue_foo_normally 10
+        if x = 1 then continue_foo_snapshot 10
         else outer_snapshot 20;;
 
 And this is indeed what is happening, at a fundamental level, when you use an expression like `abort 20`. Here is the original code for comparison:
         else outer_snapshot 20;;
 
 And this is indeed what is happening, at a fundamental level, when you use an expression like `abort 20`. Here is the original code for comparison:
@@ -404,11 +404,11 @@ into this:
     in let outer_snapshot = fun box ->
         let foo_result = box
         in (foo_result) + 1000
     in let outer_snapshot = fun box ->
         let foo_result = box
         in (foo_result) + 1000
-    in let continue_foo_normally = fun from_value ->
+    in let continue_foo_snapshot = fun from_value ->
         let value = from_value + 100
         in outer_snapshot value
     in (* start of foo_applied_to_x *)
         let value = from_value + 100
         in outer_snapshot value
     in (* start of foo_applied_to_x *)
-        if x = 1 then continue_foo_normally 10
+        if x = 1 then continue_foo_snapshot 10
         else outer_snapshot 20;;
 
 Code written in the latter form is said to be written in **explicit continuation-passing style** or CPS. Later we'll talk about algorithms that mechanically convert an entire program into CPS.
         else outer_snapshot 20;;
 
 Code written in the latter form is said to be written in **explicit continuation-passing style** or CPS. Later we'll talk about algorithms that mechanically convert an entire program into CPS.
@@ -442,10 +442,10 @@ There are also different kinds of "syntactic sugar" we can use to hide the conti
       let outer_snapshot = fun box ->
           let foo_result = box
           in (foo_result) + 1000
       let outer_snapshot = fun box ->
           let foo_result = box
           in (foo_result) + 1000
-      in let continue_foo_normally = fun from_value ->
+      in let continue_foo_snapshot = fun from_value ->
           let value = from_value + 100
           in outer_snapshot value
           let value = from_value + 100
           in outer_snapshot value
-      in if x = 1 then continue_foo_normally 10
+      in if x = 1 then continue_foo_snapshot 10
       else outer_snapshot 20;;
 
 # let test_shift x =
       else outer_snapshot 20;;
 
 # let test_shift x =