
[Christian Tismer]
... Yup. With a little counting, it was easy to survive:
def main(): global a a=2 thing (5) a=a-1 if a: saved.throw (0)
Did "a" really need to be global here? I hope you see the same behavior without the "global a"; e.g., this Scheme: (define -cont- #f) (define thing (lambda (n) (if (= n 2) (call/cc (lambda (k) (set! -cont- k)))) (display "n == ") (display n) (newline) (if (= n 0) (begin (display "Done!") (newline)) (thing (- n 1))))) (define main (lambda () (let ((a 2)) (thing 5) (display "a is ") (display a) (newline) (set! a (- a 1)) (if (> a 0) (-cont- #f))))) (main) prints: n == 5 n == 4 n == 3 n == 2 n == 1 n == 0 Done! a is 2 n == 2 n == 1 n == 0 Done! a is 1 Or does brute-force frame-copying cause the continuation to set "a" back to 2 each time?
Weird enough
Par for the continuation course! They're nasty when eaten raw.
and needs a much better interface.
Ya, like screw 'em and use threads <wink>.
But finally I'm quite happy that it worked so smoothly after just a couple of hours (well, about six :)
Yup! Playing with Python internals is a treat. to-be-continued-ly y'rs - tim