WeakPointerObj( list )
WeakPointerObj returns a weak pointer object which contains the same
subobjects as list, that is it returns a shallow weak copy of list.
gap> w := WeakPointerObj( [ 1, , [2,3], fail, rec() ] );
WeakPointerObj( [ 1, , [ 2, 3 ], fail, rec( ) ] )
gap> GASMAN("collect");
gap> w;
WeakPointerObj( [ 1, , , fail ] )
Note that w has failed to keep its list and record subobjects alive during
the garbage collection. Certain subobjects, such as small integers and
elements of small finite fields, are not stored in the workspace, and so are
not subject to garbage collection, while certain other objects, such as the
Boolean values, are always reachable from global variables or the kernel and
so are never garbage collected.
Subobjects reachable without going through a weak pointer object do not evaporate, as in:
gap> l := [1,2,3];;
gap> w[1] := l;;
gap> w;
WeakPointerObj( [ [ 1, 2, 3 ], , , fail ] )
gap> GASMAN("collect");
gap> w;
eakPointerObj( [ [ 1, 2, 3 ], , , fail] )
Note also that the global variables last, last2 and last3 will keep
things alive -- this can be confusing when debugging.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual