source: project/demonstrations/continuations/README @ 21231

Last change on this file since 21231 was 21231, checked in by felix winkelmann, 10 years ago

added link

File size: 1.6 KB
Line 
1== README for ''continatuations''
2
3Code that demonstrates the use of continuations.
4
5{{suspensions.scm}} saves the current state of an executing
6program using the {{suspension}} extension.
7
8First compile the program and run it, passing the loop-index
9at 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
21The state is written to the file {{state}}, we can use
22{{chicken-dump}} (part of the {{suspension}} extension) to dump the
23contents 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
51Now we run the example program and tell it to resume from the saved
52state:
53
54  % suspensions state
55  start.
56  6
57  7
58  8
59  9
60  end.
61
62An excellent tutorial abouth the applications of continuations
63can be found here:
64
65    [[http://matt.might.net/articles/programming-with-continuations--exceptions-backtracking-search-threads-generators-coroutines/]]
Note: See TracBrowser for help on using the repository browser.