Next: , Previous: , Up: Garbage Collection   [Contents][Index]


2.7.3 Weak Pointers

A weak pointer provides a way to maintain a reference to an object without preventing an object from being garbage collected. If the garbage collector discovers that the only pointers to an object are weak pointers, then it breaks the weak pointers and deallocates the object.

Function: extensions:make-weak-pointer object
Function: extensions:weak-pointer-value weak-pointer

make-weak-pointer returns a weak pointer to an object. weak-pointer-value follows a weak pointer, returning the two values: the object pointed to (or nil if broken) and a boolean value which is nil if the pointer has been broken, and true otherwise.