[plt-scheme] Weak boxes and uncollected values

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

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.

An example interaction with mzscheme:

> (define A (make-weak-box 'symbol))
> (define B (make-weak-box (list 1 2 3)))
> (define C (make-weak-box (+ 1 2 3)))
> (define D (make-weak-box (not #f)))
> (map weak-box-value (list A B C D))
(symbol (1 2 3) 6 #t)
> (collect-garbage)
> (map weak-box-value (list A B C D))
(#f #f 6 #t)

The symbol and list are collected; the fixnum and boolean are not.  Is
this the intended behavior?  Is there a way to identify these values
beforehand, so this behavior can be anticipated?

-- 
Carl Eastlund


Posted on the users mailing list.