[racket-dev] weak boxes in a script

From: David Vanderson (david.vanderson at gmail.com)
Date: Wed Mar 16 17:09:45 EDT 2011

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)
 > (collect-garbage)
 > (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


Posted on the dev mailing list.