Sets the weakness state of an array.
hcl
set-array-weak array weakp => weakp
array⇩ |
A non-displaced array, with array-element-type t . |
weakp⇩ |
A generalized boolean. |
weakp |
A generalized boolean. |
The function set-array-weak
sets the weakness state array to weakp.
If weakp is non-nil, then array is made weak. If weakp is nil
, then array is made non-weak.
By default, arrays are non-weak, and they keep alive all the objects that are stored in them. A weak array may remove a pointer if the object that it points to is not pointed to from somewhere else. When a pointer is removed like this, it is replaced in array with nil
.
Pointers are replaced by nil
after a garbage collector (GC) operation that identifies that they can be replaced. This means that if the object that is pointed to has been promoted to a higher generation, a garbage collection of the higher generation is required to remove the pointer. Note that by default the system does not automatically GC the blocking generation or higher.
The weakness state of an array can be changed many times.
In all implementations, array must not be a displaced array, and the array-element-type of array must be t
.
In 64-bit LispWorks, an additional requirement is that array must be an adjustable array. However, you can make a non-adjustable weak array using make-array with the :weak t
arguments.
set-array-weak
can be called at any moment.
An array can be made weak at creation time using the :weak
argument to make-array.
array-weak-p
copy-to-weak-simple-vector
set-hash-table-weak
make-array
mark-and-sweep
11.6.8 Freeing of objects by the GC
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35