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




_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to