<p dir="ltr">Because quote maintains its own interning table, I believe. Also, at a REPL, the syntax of the quote may still be accessible.</p>
<div class="gmail_quote">On Jan 28, 2014 1:37 PM, "Jos Koot" <<a href="mailto:jos.koot@gmail.com">jos.koot@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<u></u>
<div>
<div dir="ltr" align="left"><span><font face="Courier New"><font color="#0000ff">Thanks.</font></font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New">I dont know why Racket wont release quoted literals
after disappearing, but your answer is clear.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New">Jos</font></span></div><br>
<blockquote style="PADDING-LEFT:5px;MARGIN-LEFT:5px;BORDER-LEFT:#0000ff 2px solid;MARGIN-RIGHT:0px" dir="ltr">
<div lang="en-us" dir="ltr" align="left">
<hr>
<font face="Tahoma"><b>From:</b> Carl Eastlund
[mailto:<a href="mailto:carl.eastlund@gmail.com" target="_blank">carl.eastlund@gmail.com</a>] <br><b>Sent:</b> martes, 28 de enero de 2014
18:13<br><b>To:</b> Jos Koot<br><b>Cc:</b> Racket Users<br><b>Subject:</b> RE:
[racket] FW: weakly held symbols?<br></font><br></div>
<div></div>
<p dir="ltr">Racket will generally not release keys that are quoted literals in
your program. Try building your keys using symbol->string.</p>
<div class="gmail_quote">On Jan 28, 2014 8:16 AM, "Jos Koot" <<a href="mailto:jos.koot@gmail.com" target="_blank">jos.koot@gmail.com</a>> wrote:<br type="attribution">
<blockquote class="gmail_quote" style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid"><u></u>
<div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span>Things
work now as I expect for weak boxes, but I am still confused about weak hash
tables. I do the following:</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New">#lang
racket</font></div>
<div> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New">(define h
(make-weak-hash))</font></div>
<div> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New">(define
keys<br> (for/list ((key (in-list '(a b c d e f))))<br>
(make-weak-box key) ; <--- 1<br>; key ; <--- 2<br>
))</font></div>
<div> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New">(define
(enter key value)<br> (will-register will-executor value
will-proc)<br> (set! enter-counter (add1
enter-counter))<br> (hash-set! h key value))</font></div>
<div> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New">(define-syntax-rule (while condition expr
...)<br> (let loop () (when condition expr ... (loop))))</font></div>
<div> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New">(define
will-executor (make-will-executor))<br>(define (will-proc v) (set!
release-counter (add1 release-counter)) #t)<br>(define enter-counter
0)<br>(define release-counter 0)<br>(define range (in-range 6))<br>(for
((key (in-list keys)) (value range)) (enter key (list value)))<br>(list
enter-counter release-counter) ; -> (6 0) ok<br>h ; -> hash with 6
entries, ok<br>(set! keys #f)<span> ; discard all
keys</span><br>(collect-garbage) (collect-garbage)(collect-garbage)
(collect-garbage)<br>(while (will-try-execute will-executor))<br>(list
enter-counter release-counter) ; -> (6 6) ok<br>h ; -> empty
hash, ok</font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"></font> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New">So far
ok. However, when commenting out line <--- 1 and uncommenting line
<--- 2, I would expect the same results, but I find:</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New">(6 0) ;
ok</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New">hash
with 6 entries ; ok</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New">(6 0) ;
a surptrise for me</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New">hash
with 6 entries ; a surprise for me</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New">This is
the cause of my confusion. Surely I am misinterpreting the docs. Help much
appreciated.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New">Thanks
again, Jos</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New"></font></span> </div><br>
<blockquote style="PADDING-LEFT:5px;MARGIN-LEFT:5px;BORDER-LEFT:#0000ff 2px solid;MARGIN-RIGHT:0px" dir="ltr">
<div lang="en-us" dir="ltr" align="left">
<hr>
<font face="Tahoma"><b>From:</b> Carl Eastlund [mailto:<a href="mailto:carl.eastlund@gmail.com" target="_blank">carl.eastlund@gmail.com</a>] <br><b>Sent:</b> martes, 28 de
enero de 2014 1:28<br><b>To:</b> Jos Koot<br><b>Cc:</b> Racket
Users<br><b>Subject:</b> Re: [racket] FW: weakly held
symbols?<br></font><br></div>
<div></div>
<div dir="ltr">
<div>
<div>This isn't a typo. The docs are talking about the properties of
the symbol tables for interned and unreadable symbols. There is no
symbol table for uninterned symbols, so it wouldn't mean anything to talk
about it.<br><br></div>Here's what this means for an interned symbol: you
can create one, and while a reference to it exists, it stays in the symbol
table. Any time you intern the same string, you'll get back that
symbol. However, if all references to that symbol vanish, the symbol
table is free to release that symbol. If anyone interns the same
string again later, a new symbol will be created. For nearly all
purposes, this is completely transparent, because you couldn't possibly
have a copy of the old symbol to compare. There's almost no way to
tell that the symbol you got before and the one you got after were
different. The only way you'd ever know would be either by tracking
memory use statistics, or by comparing the results of something like
eq-hash-code, neither of which should be surprising to find out behaves
impurely.<br></div></div>
<div class="gmail_extra"><br clear="all">
<div>Carl Eastlund</div><br><br>
<div class="gmail_quote">On Mon, Jan 27, 2014 at 5:53 PM, Jos Koot <span dir="ltr"><<a href="mailto:jos.koot@gmail.com" target="_blank">jos.koot@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid"><u></u>
<div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span>It
appears that my previous email was not sent completely. Sorry for that.
Here is the complete question.</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span></span></font> </div>
<div dir="ltr" align="left"><span>
<div>
<div><font color="#0000ff" face="Courier New"><span>Hi to
all,</span></font></div>
<div><font color="#0000ff" face="Courier New"><span></span></font> </div>
<div><font color="#0000ff" face="Courier New"><span>Section "3.6 symbols"
of the Racket reference manual states:</span></font></div>
<div><font color="#0000ff" face="Courier New"><span></span></font> </div></div>
<div><span><font face="Courier New"><font color="#0000ff"><font size="+0">Interned and unreadable symbols are only weakly held ... but a
symbol maay disappear when ... used as the key in a weak hash table
..."<span>.</span></font></font></font></span></div>
<div><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span></span></font></font></font></span> </div>
<div><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span>I would
understand:</span></font></font></font></span></div>
<div><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span></span></font></font></font></span> </div>
<div><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span><span><font face="Courier New"><font color="#0000ff"><font size="+0">UNINTERNED and unreadable symbols are only weakly held ...
but a symbol may disappear when ... used as the key in a weak hash table
..."<span>.</span></font></font></font></span></span></font></font></font></span></div>
<div><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span></span></font></font></font></span></span></font></font></font></span> </div>
<div><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span>May be just a typo, but as I am not sure I understand the
docs well, I post my question here instead of posting a bug
report.</span></font></font></font></span></span></font></font></font></span></div>
<div><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span></span></font></font></font></span></span></font></font></font></span> </div>
<div><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span><span><font face="Courier New"><font color="#0000ff"><font size="+0"><span>Greetings,
Jos</span></font></font></font></span></span></font></font></font></span></div></span></div></div><br>____________________<br>
Racket Users list:<br> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br><br></blockquote></div><br></div></blockquote></div></blockquote></div></blockquote></div>
</blockquote></div>