6.6 The GASMAN Interface for Weak Pointer Objects

The key support for weak pointers is in gasman.c and gasman.h. This document assumes familiarity with the rest of the operation of GASMAN. A kernel type (tnum) of bags which are intended to act as weak pointers to their subobjects must meet three conditions. Firstly, the marking function installed for that tnum must use MarkBagWeakly for those subbags, rather than MARK_BAG. Secondly, before any access to such a subbag, it must be checked with IS_WEAK_DEAD_BAG. If that returns true, then the subbag has evaporated in a recent garbage collection and must not be accessed. Typically the reference to it should be removed. Thirdly, a sweeping function must be installed for that tnum which copies the bag, removing all references to dead weakly held subbags.

The files weakptr.c and weakptr.h use this interface to support weak pointer objects. Other objects with weak behaviour could be implemented in a similar way.

[Top] [Previous] [Up] [Index]

GAP 4 manual
February 2000