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

Juan Jose Garcia-Ripoll jjgarcia at users.sourceforge.net
Sun Apr 27 13:28:43 UTC 2008

On Sun, Apr 27, 2008 at 1:16 PM, Marco Gidde <marco.gidde at tiscali.de> wrote:
> 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 second patch will probably be applied without further changes.
There is one issue left, which is to make sure that the pointer stored
in the finalizer is considered as a root when garbage collecting:
otherwise the library will simply ignore it.

Regarding the other things, the implementation I had in mind would
keep an association from objects to weak pointers. When creating a
hash table of type weak, for each key we would look up the association
and use the weak pointer as a key. From time to time these hash tables
would have to be cleaned up, removing entries with weak pointers that
are empty. This can be done at lookup time or in some other way.

Such an implementation would not be very obstrussive and would remove
the need to keep track which objects are stored in which hash tables.
Because the other alternative is to change the data for the finalizer
whenever an object is added or removed from a weak hash table.

The biggest inconvenient is that weak hash tables can only be
associated by EQ -- or perhaps one can change this.

I also find the idea of having unique weak pointers interesting in
itself. It minimizes the overhead of weak pointers and uses  the fact
that they should be inmutable structures (at least from the user's
point of view)


Facultad de Fisicas, Universidad Complutense,
Ciudad Universitaria s/n Madrid 28040 (Spain)

More information about the ecl-devel mailing list