tried to clarify the ephemeron docs by setting the stage for the precise definition that was already there a little bit.

This commit is contained in:
Robby Findler 2010-11-28 16:04:13 -06:00
parent c123a8cc5d
commit 62f3d7e254

View File

@ -37,13 +37,20 @@ Returns @racket[#t] if @racket[v] is a weak box, @racket[#f] otherwise.}
@;------------------------------------------------------------------------ @;------------------------------------------------------------------------
@section[#:tag "ephemerons"]{Ephemerons} @section[#:tag "ephemerons"]{Ephemerons}
An @deftech{ephemeron} is similar to a weak box (see An @deftech{ephemeron} is a generalization of a weak box (see
@secref["weakbox"]), except that @secref["weakbox"]). Instead of just containing one value, it holds two,
the value of the ephemeron, plus a key. Like a weak box, the
value in the ephemeron may be replaced by @racket[#f], but it does
this when the key is no longer reachable. In addition, the memory
manager specially treats links from the value to the key.
A weak box can be seen as a specialization of an ephemeron where
the key and value are the same.
More precisely,
@itemize[ @itemize[
@item{an ephemeron contains a key and a value; the value can be @item{the value in an ephemeron is replaced
extracted from the ephemeron, but the value is replaced
by @racket[#f] when the automatic memory manager can prove that by @racket[#f] when the automatic memory manager can prove that
either the ephemeron or the key is reachable only through weak either the ephemeron or the key is reachable only through weak
references (see @secref["weakbox"]); and} references (see @secref["weakbox"]); and}
@ -57,7 +64,7 @@ An @deftech{ephemeron} is similar to a weak box (see
] ]
In particular, an ephemeron can be combined with a weak hash table On particularly common use of ephemerons is to combined them with a weak hash table
(see @secref["hashtables"]) to produce a mapping where the memory (see @secref["hashtables"]) to produce a mapping where the memory
manager can reclaim key--value pairs even when the value refers to the manager can reclaim key--value pairs even when the value refers to the
key. key.