[Ecls-list] *finalize-hook* ??
Julian Stecklina
der_julian at web.de
Tue Nov 29 08:36:05 UTC 2005
On Tue, 29 Nov 2005 16:38:35 +0100
Juan Jose Garcia Ripoll <lisp at arrakis.es> wrote:
> On Tue, 2005-11-29 at 16:08 +0100, Goffioul Michael wrote:
> > Is it possible to add finalization capabilities to ECL? What I'd
> > like is to be able to register a handler for a given object, which
> > would be called when the object is GC'ed (the handler would be
> > called with the object as argument).
>
> The problem is that AFAIK it is not safe to call the allocation
> routines from finalizer routines and lisp code cannot be guaranteed
> to be cons-free. Not even compiled one. If you want to add
> finalizers, they should be low-level C code and you can attach them
> using the Boehm-Weiser routines (See alloc_2.d for an example).
I think the solution is what Allegro CL does: If the GC hits an object
with an attached finalizer, it does not collect it, but runs its
finalizer after the collection run and removes the attached finalizer
thereafter. If the object is not resurrected by the finalizer (not good,
but possible), the object is collected on the next GC run.
You have to order the executions of finalizers, though, which is not
very nice. But then again, a simple finalization mechanism would do for
the moment, IMHO.
Regards,
--
Julian Stecklina
When someone says "I want a programming language in which I
need only say what I wish done," give him a lollipop. - Alan Perlis
More information about the ecl-devel
mailing list