[plt-scheme] Weak boxes and uncollected values

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue Jul 25 15:31:55 EDT 2006

On 7/25/06, Carl Eastlund <cce at ccs.neu.edu> wrote:
> On 7/25/06, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > At Tue, 25 Jul 2006 15:05:51 -0400, "Carl Eastlund" wrote:
> > > > > Certain values, such as #t and fixnum integers, don't "vanish" from
> > > > > weak boxes after garbage collection, even when there don't seem to be
> > > > > any outside references.
> >
> > There are still references somewhere. In particular, if you read `#t',
> > you get back an object that is `eq?' to the key in the hash table.
> > That's true for `7', too, if you use 7 as a key.
> >
> > Since you can still reach the key, the mapping stays in the hash table.
> Are you trying to tell me mzscheme keeps around a reference to every
> fixnum the program ever generates, just in case it might happen to
> compute the same number again?  I don't believe you, or I'm seriously
> misunderstanding your statement.

Wait, I think I see your point.  You are motivating weak box behavior
by weak hash table behavior.  Because values eq? to #t and 4 can be
generated later in the program, hash table entries with those keys
must be kept indefinitely.  So for consistency, weak box values are
kept as well.

Carl Eastlund

Posted on the users mailing list.