From c48521340337270a5b9bb439045af44ff0dc2b5a Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Tue, 30 Nov 2010 18:42:07 -0500 Subject: [PATCH] coroutines tweak Signed-off-by: Jim Pryor --- coroutines_and_aborts.mdwn | 48 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/coroutines_and_aborts.mdwn b/coroutines_and_aborts.mdwn index c6b5f451..a7eccfc4 100644 --- a/coroutines_and_aborts.mdwn +++ b/coroutines_and_aborts.mdwn @@ -416,16 +416,6 @@ we can imagine a box: and as we're about to enter the box, we want to take a snapshot of the code *outside* the box. If we decide to abort, we'd be aborting to that snapshotted code. - 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: @@ -496,6 +486,44 @@ We can get that by some further rearranging of the code: And this is indeed what is happening, at a fundamental level, when you use an expression like `abort 20`. + + A similar kind of "snapshotting" lets coroutines keep track of where the left off, so that they can start up again at that same place. These snapshots are called **continuations** because they represent how the computation will "continue" once some target code (in our example, the code in the box) delivers up a value. -- 2.11.0