[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Goops and finalizing
From: |
Michael Livshin |
Subject: |
Re: Goops and finalizing |
Date: |
06 Sep 2000 22:36:46 +0300 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (20 Minutes to Nikko) |
"Lars J. Aas" <address@hidden> 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