Next Prev Up Top Contents Index

set-hash-table-weak

Function
Summary

Sets the weakness state of a hash-table.

Package

hcl

Signature

set-hash-table-weak hash-table weak => weakness-state

Arguments

hash-table

A hash-table.

weak

Sets the weakness state of hash-table. Value may be:

: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.

Values

Returns weak, unless t was passed, when :value is returned.

Description

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 allows entries to be removed if there are no other pointers to them. The weakness-state tells the system which entries may be removed like this.

Entries that can be removed are removed after a garbage collector 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 (mark and sweep) of the higher generation is required to remove them from the table. Note that by default the system does not automatically call mark-and-sweep on generation 2 or higher.

The weakness-state of a hash-table can be changed repeatedly, at any time, at any point using any of the weak values listed above. It can also be set by make-hash-table .

See also
make-hash-table
mark-and-sweep
set-array-weak

LispWorks Reference Manual - 25 Jul 2003

Next Prev Up Top Contents Index