[plt-scheme] equivalent to atexit?

From: YC (yinso.chen at gmail.com)
Date: Tue Mar 24 00:59:36 EDT 2009

On Mon, Mar 23, 2009 at 8:57 PM, Chongkai Zhu <czhu at cs.utah.edu> wrote:

> It seems that memory served me wrong: only when writing C code, you can put
> objects under the management of custodians.
> http://docs.plt-scheme.org/inside/Custodians.html
>
> For Scheme code, dynamic-wind would be more appropriate.
>

Thanks Chongkai for thoughts on custodian & dynamic-wind.

I think dynamic-wind doesn't fit the long-living objects I am describing,
unless the dynamic-wind is used at the top level.  I am thinking of objects
that live as long as modules (i.e. from the point of require to the point of
program exit).

An example is a module that abstracts its persistence mechanism.  Let's say
we have a module foo that provides log-foo-event, but doesn't expose the
underlying instantiation and closure of database.  So when you require
module foo, the database is automatically instantiated in the background.

The abstracted database connection doesn't close until the module is
unloaded (generally when mzscheme exits), and it needs some explicit clean
up code (like ensurely there are no leftover locks etc).

Custodians do not appear to have ability to execute custom code when an
object is  being shutdown.

Will appears to run when the object is not reachable, but such long living
objects will probably be always reachable, so it also doesn't appear to be a
fit.

If there is something that combines the feature of custodian & will it would
probably do the trick.

Thanks,
yc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090323/f9484b08/attachment.html>

Posted on the users mailing list.