Line | |
---|
1 | == README for ''continatuations'' |
---|
2 | |
---|
3 | Code that demonstrates the use of continuations. |
---|
4 | |
---|
5 | {{suspensions.scm}} saves the current state of an executing |
---|
6 | program using the {{suspension}} extension. |
---|
7 | |
---|
8 | First compile the program and run it, passing the loop-index |
---|
9 | at which you want to suspend the execution: |
---|
10 | |
---|
11 | % csc suspensions.scm |
---|
12 | % suspensions 5 |
---|
13 | start. |
---|
14 | 1 |
---|
15 | 2 |
---|
16 | 3 |
---|
17 | 4 |
---|
18 | 5 |
---|
19 | saving state ... |
---|
20 | |
---|
21 | The state is written to the file {{state}}, we can use |
---|
22 | {{chicken-dump}} (part of the {{suspension}} extension) to dump the |
---|
23 | contents of this file: |
---|
24 | |
---|
25 | % chicken-dump state |
---|
26 | |
---|
27 | File: state |
---|
28 | |
---|
29 | 0: |
---|
30 | #0: procedure: |
---|
31 | #1:(id) string "f_188:suspension_scm" |
---|
32 | #2:[1] procedure: |
---|
33 | #3:(id) string "f_86:suspensions_scm" |
---|
34 | #4:[1] procedure: |
---|
35 | #5:(id) string "f_150:suspensions_scm" |
---|
36 | #6:[1] procedure: |
---|
37 | #7:(id) string "values_continuation" |
---|
38 | #8:[1] procedure: |
---|
39 | #9:(id) string "f_161:suspension_scm" |
---|
40 | #10:[1] lambda info #<lambda info (suspension#continuation-drop . results42)> |
---|
41 | #11:[2] procedure: |
---|
42 | #12:(id) string "termination_continuation" |
---|
43 | #13:[2] vector |
---|
44 | #14:[0] procedure: |
---|
45 | #15:(id) string "f_73:suspensions_scm" |
---|
46 | [1] fixnum 5 |
---|
47 | [2] back reference -> #13 |
---|
48 | #16:[3] lambda info #<lambda info (doloop19 i21)> |
---|
49 | [3] fixnum 5 |
---|
50 | |
---|
51 | Now we run the example program and tell it to resume from the saved |
---|
52 | state: |
---|
53 | |
---|
54 | % suspensions state |
---|
55 | start. |
---|
56 | 6 |
---|
57 | 7 |
---|
58 | 8 |
---|
59 | 9 |
---|
60 | end. |
---|
Note: See
TracBrowser
for help on using the repository browser.