This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: Goops and finalizing
- To: "Lars J. Aas" <larsa at sim dot no>
- Subject: Re: Goops and finalizing
- From: Michael Livshin <mlivshin at bigfoot dot com>
- Date: 06 Sep 2000 22:36:46 +0300
- Cc: guile-user at gnu dot org
- List-Id: <guile-user.gnu.org>
- Organization: who? me?
- References: <20000906195120.A29105@sim.no>
"Lars J. Aas" <larsa@sim.no> writes:
> Is there any way to have some sort of destructor for a goops class that
> kicks in before an instance is garbage collected? I didn't see any doc
> on it...
weeeeell.
first, be aware that you don't get _any_ guarantee that any object
will ever die, much less die in a timely fashion. you surely know
that, but just in case.
you have two choices when it comes to finalization:
* use guardians. you can read up on them in the
function-documentation for `make-guardian'. this is a generic
facility, not specific to GOOPS objects, and in general pretty neat
and Schemey.
* replace the `free' procedure in the class vtable with something that
both frees the memory and does something else. this is a hack, can
only be done in C, is a hack, requires you to read the code in
struct.c, is a hack, the interface will surely change sometime
"soon", and did I mention it's a hack? there ;).
> (define-method finalize ((class <class>))
> [finalize instance])
this is kinda impossible in a garbage-collected language, as it would
require calling Scheme code inside the GC.
--
Hit the philistines three times over the head with the Elisp reference manual.
-- Michael A. Petonic
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user