chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] srfi-18 and dynamic wind problem


From: Alaric Snell-Pym
Subject: Re: [Chicken-users] srfi-18 and dynamic wind problem
Date: Mon, 7 Apr 2008 10:45:50 +0100


On 6 Apr 2008, at 5:41 am, Jim Ursetto wrote:
I'm seeing some odd behavior when using dynamic-wind within a thread.
If an error occurs during the thunk, the 'after' portion is never
called nor are any subsequent statements. thread-join! then throws
an exception.


I was also worrying why the example from srfi-18 didn't work, which
would seem related:

#;1>     (with-output-to-file
--->      "foo"
--->      (lambda ()
--->        (let ((k (call-with-current-continuation
--->                  (lambda (exit)
--->                    (with-output-to-file
--->                     "bar"
--->                     (lambda ()
--->                       (dynamic-wind
--->                        (lambda () (write '(b1)))
--->                        (lambda ()
--->                          (let ((x (call-with-current-continuation
--->                                    (lambda (cont) (exit cont)))))
--->                            (write '(t1))
--->                            x))
--->                        (lambda () (write '(a1))))))))))
--->          (if k
--->              (dynamic-wind
--->               (lambda () (write '(b2)))
--->               (lambda ()
--->                 (with-output-to-file
--->                  "baz"
--->                  (lambda ()
--->                    (write '(t2))
--->                    ; go back inside (with-output-to-file
"bar" ...)
--->                    (k #f))))
--->               (lambda () (write '(a2))))))))
#;2>
alaric$ ls
bar baz foo
alaricn$ cat foo
alaric$ cat bar
(b1)(a1)(b2)
alaric$ cat baz
(t2)(a2)(b1)(t1)(a1)

(b1) and (a1) are written to bar, but then the current output port is
still to bar when (b2) is written, outside of the scope of the with-
output-to-file "bar"; it should go to foo. Likewise, (a2) gets
written to baz and not to foo, and (b1)(t1)(a1) goes to baz and not bar.

ABS

--
Alaric Snell-Pym
Work: http://www.snell-systems.co.uk/
Play: http://www.snell-pym.org.uk/alaric/
Blog: http://www.snell-pym.org.uk/?author=4






reply via email to

[Prev in Thread] Current Thread [Next in Thread]