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

Marco Gidde marco.gidde at tiscali.de
Sun Apr 27 11:16:51 UTC 2008


Found some time yesterday and implemented the suggested stuff. Attached
are two patches, the first implements weak pointers, the other makes
internal and user finalizers distinct.

The weak pointer patch adds the new type ecl_weakpointer to the type
union and defines two user level functions, analogous to those in SBCL:
(SI:MAKE-WEAK-POINTER OBJ) defines a weak pointer to obj and
(SI:WEAK-POINTER-VALUE obj) tries to retrieve the value. Two values are
returned, the first is the original object or NIL, the second is T if
successful or NIL if the object is already garbage collected.

The finalizer patch adds one internal function ecl_set_finalizer(obj, f)
which is only used within ECL, is not exported, and sets the internal
finalizer which can be either T, NIL or a real function.
si_set_finalizer(obj, f) does not interfere with the internal finalizers
any more. This is done by storing a CONS cell instead of the mere
function. ecl_set_finalizer always accesses the CAR and si_set_finalizer
the CDR of this cell. The standard finalizer is still piggy packed and
will be called when either the CAR or the CDR is not NIL.

I tried the patches with the Boehm-Weiser collector that is part of ECL
and they seem to work. I also tried to compile with --enable-boehm=no to
make sure I did not break something with that configuration, but
compilation failed with or without the patches.

Will take a closer look now at how to implement weak hashes without
messing the code up too bad :-)


Regards, Marco


-------------- next part --------------
A non-text attachment was scrubbed...
Name: weak-pointer.patch
Type: text/x-patch
Size: 8660 bytes
Desc: weakpointer
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20080427/76156658/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: finalizer.patch
Type: text/x-patch
Size: 8222 bytes
Desc: finalizer
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20080427/76156658/attachment-0001.bin>


More information about the ecl-devel mailing list