I have here some objects whose creation involves starting external
processes. I would like these processes to be properly shut down when
the corresponding objects are garbage-collected.
So I tried using `add-finalizer!' for this purpose and couldn't get it
to work. Here is an example:
Welcome to scsh 0.6.7 (RC 1)
Type ,? for help.
> ,open define-record-types primitives
> (define-record-type foo :foo
(really-make-foo x)
(x foo:x))
> (define bar #f)
> (define (make-foo x)
(let ((new-foo (really-make-foo x)))
(add-finalizer! new-foo
(lambda (obj)
(set! bar 1)))
new-foo))
> (make-foo 43)
'#{Foo}
> ,collect
Before: 10608482 words free in semispace
After: 10673414 words free in semispace
> bar
#f
>
I was expecting `bar' to be 1 at this point. The same example works
as expected under Scheme 48 1.3.
Isn't this the way it's supposed to work?
Thanks in advance for any insight.
Emilio
--
Emilio C. Lopes <eclig@gmx.net>
Munich, Germany
|