Thanks so much, that makes perfect sense.

On 03/16/2011 02:16 PM, Carl Eastlund wrote:

I believe you are seeing the difference between modules and the REPL.
At the REPL, each expression is compiled, run, and discarded.  This
yields the behavior you expect.  But a "#lang" form produces a module,
which is compiled and kept for the rest of the session.  Thus, even
after garbage collection, the compiled form of the first term still

(define b (make-weak-box 'not-used))

Thus there is a reference to the symbol not-used, and it is not
garbage collected.

Carl Eastlund

On Wed, Mar 16, 2011 at 5:09 PM, David Vanderson
<>  wrote:
I'm seeing a difference between when the value in a weak box is collected.
  When I run the following interactively, the value is collected like I
expect.  But it is not collected when running in a script, or in DrRacket.
  This is v5.1 on Ubuntu x64, compiled from source.

Can someone explain the difference?

~$ racket
Welcome to Racket v5.1.
(define b (make-weak-box 'not-used))
(weak-box-value b)
(weak-box-value b)

~$ cat weak-box.rkt
#lang racket

(define b (make-weak-box 'not-used))
(weak-box-value b)
(weak-box-value b)

~$ racket weak-box.rkt

 For list-related administrative tasks:

Reply via email to