[plt-dev] symbol->string and mutability
On Thu, Jun 18, 2009 at 4:34 PM, Matthew Flatt<mflatt at cs.utah.edu> wrote:
>> >
>> > No --- symbols and keywords are GCed, so a weak hash table would work.
>> >
>> > (And weakness in hash tables isn't about whether you could synthesize
>> > the key. We have `equal?'-based hash tables with weak keys, after all.)
>>
>> I see. I tried to demonstrate this one way or another to myself with
>> a weak box containing a symbol and a call to collect-garbage, and the
>> box never "emptied". Perhaps that experiment was not conclusive;
>> maybe collect-garbage doesn't guarantee emptying of all weak boxes, or
>> I had a reference to the symbol lying around somewhere I didn't know
>> about.
>
> I tried this in the MzScheme and DrScheme (module language) REPLs:
>
> > (define b (make-weak-box 'not-used-elsewhere))
> > (weak-box-value b)
> not-used-elsewhere
> > (collect-garbage)
> > (weak-box-value b)
> #f
>
> Did you try the same thing?
Nope. I put the first line in the definitions window, which of course
put the symbol in the compiled version of the module, thus preventing
it from being GC'd. Oops.
--Carl