Next: Type annotations, Previous: Hash tables, Up: System features
Scheme48 provides an interface to weakly held references in basic weak
pointers and populations, or sets whose elements are weakly held.
The facility is in the structure weak
.
#f
Make-weak-pointer
creates a weak pointer that points to contents.Weak-pointer?
is the weak pointer disjoint type predicate.Weak-pointer-ref
accesses the value contained withinweak-pointer
, or returns#f
if there were no strong references to the contents and a garbage collection occurred. Weak pointers resemble cells, except that they are immutable and hold their contents weakly, not strongly.
Make-population
constructs an empty population.Add-to-population!
adds object to the population population.Population->list
returns a list of the elements of population. Note, though, that this can be dangerous in that it can create strong references to the population's contents and potentially leak space because of this.Walk-population
applies proc to every element in population.