Line | |
---|
1 | ;;;; suspensions.scm |
---|
2 | |
---|
3 | |
---|
4 | (use suspension utils) |
---|
5 | |
---|
6 | |
---|
7 | (define (run halt) |
---|
8 | (do ((i 1 (add1 i))) |
---|
9 | ((>= i 10)) |
---|
10 | (print i) |
---|
11 | (when (eq? i halt) |
---|
12 | (call/cc |
---|
13 | (lambda (k) |
---|
14 | (continuation-suspend |
---|
15 | (lambda (state) |
---|
16 | (print "saving state ...") |
---|
17 | (with-output-to-file "state" |
---|
18 | (cut display state)) |
---|
19 | (exit)))))))) |
---|
20 | |
---|
21 | (let* ((args (command-line-arguments)) |
---|
22 | (x (and (pair? args) (car args)))) |
---|
23 | (print "start.") |
---|
24 | (with-limited-continuation |
---|
25 | (lambda () |
---|
26 | (cond ((and x (string->number x)) => run) |
---|
27 | (x (continuation-resume (read-all x) #f)) |
---|
28 | (else |
---|
29 | (print "please pass either a number or a filename."))) |
---|
30 | (print "end.")))) |
---|
31 | |
---|
32 | |
---|
Note: See
TracBrowser
for help on using the repository browser.