[Ecls-list] Finalizer, weak pointer, weak hashes etc.

Marco Gidde marco.gidde at tiscali.de
Thu Apr 24 19:32:41 UTC 2008


while thinking about weak pointers and hashes in ECL I read the sources
of the finalization code in alloc_2.d and found a problem: since there
is no distinction between finalizers defined by user code and internal
finalizers, the user can easily turn of the internal object finalization
(ie. closing streams) with

(si:set-finalizer obj nil)

If set-finalizer got an optional third argument INTERNAL, which should
be invisible to user code, it could register a cons cell instead of the
function object, with the CAR being an internal finalizer or T and the
CDR being the user's definition. With this approach a second internal
finalizer additional to standard_finalizer(...) could be defined, for
instance to clean up a hash table with weak keys and/or values.

Weak pointers on the other hand seem to be quite simple: define a new
type with a pointer to cl_object, allocate this cell with malloc_atomic
and let GC_general_register_disappearing_link nullify it if appropriate.

With these building blocks implementing weak hash tables is still some
amount of work, but at least doable.

What did I miss? ;-)

Regards, Marco

More information about the ecl-devel mailing list