Sets the weakness state of a hash-table.
hcl
set-hash-table-weak hash-table weak &optional free-function => weak
hash-table⇩ |
A hash-table. |
weak⇩ |
One of t , :value , :key , :both , :one , :either or nil . |
free-function⇩ |
A designator for a function of two arguments, or nil . |
weak |
One of t , :value , :key , :both , :one , :either or nil . |
The function set-hash-table-weak
sets the weakness state of hash-table to weak.
By default, hash-tables are not weak, which means that they keep alive all the keys and the values in the table.
A weak hash-table has a non-nil weak-kind, which allows entries to be removed if there are no other pointers to them. The weak-kind tells the system which entries may be removed like this.
Entries that can be removed are removed after a garbage collector (GC) operation which identifies that they can be removed. This means that if the relevant object(s) (the key or the value) have been promoted to a higher generation, a garbage collection (GC) of the higher generation is required to remove them from the table. Note that by default the system does not automatically GC the blocking generation or higher.
The weak-kind of a hash-table can be set initially by make-hash-table and can be changed repeatedly, at any time, by calling set-hash-table-weak
with the following values of weak:
:value or t |
An entry is kept if there is a pointer to the value from another object. |
:key |
An entry is kept if there is a pointer to the key from another object. |
:both |
An entry is kept if there are pointers to both the key and the value. |
:one or :either |
An entry is kept if there is a pointer to either the key or the value. |
nil |
Make the hash-table non-weak. All entries are kept. |
If free-function is non-nil then it specifies a free function as described for make-hash-table. It has no effect if weak-kind is nil
.
The return value weak is the same as the argument weak.
hash-table-weak-kind
make-hash-table
mark-and-sweep
set-array-weak
11.6.8 Freeing of objects by the GC
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35