This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: The taming of the before-gc-hook (was Re: Upcoming 1.3.2 release)
Jost Boekemeier <jostobfe@calvados.zrz.TU-Berlin.DE> writes:
> I haven't red the whole context so the following may lead into a
> differend direction but a per object function that gets called when
> the garbage collector attempts to collect an object would be nice.
>
> Something like Java's finit function. This hook may be a C level
> hook and should only be used to invalidate c structures associated
> with the object (file handles or in my case a pointer to a C function
> that must be invalidated -- at the moment I track weak observers by keeping
> indirect references into a weak observer array).
Sure.
Look at scm_set_smob_free and scm_set_port_free.
> Btw: What are guardians if I may ask stupid questions?
It's a nice mechanism for specifying side-effects when objects are
GC:d.
From NEWS:
** New function: make-guardian
This is an implementation of guardians as described in
R. Kent Dybvig, Carl Bruggeman, and David Eby (1993) "Guardians in a
Generation-Based Garbage Collector" ACM SIGPLAN Conference on
Programming Language Design and Implementation, June 1993
ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/pubs/guardians.ps.gz