<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 11.00.9600.16476"></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 face="Courier New"><SPAN
class=877500613-28012014>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 size=2 face="Courier New"><SPAN
class=877500613-28012014></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 face="Courier New">#lang
racket</FONT></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 face="Courier New">(define h
(make-weak-hash))</FONT></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 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 size=2 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 size=2
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 size=2 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 class=877500613-28012014> ; 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 size=2
face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 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 class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New"></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New">(6 0) ; ok</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New">hash with 6 entries ; ok</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New">(6 0) ; a surptrise for me</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New">hash with 6 entries ; a surprise for
me</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New"></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 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 class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New"></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New">Thanks again, Jos</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New"></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 face="Courier New"></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=877500613-28012014><FONT color=#0000ff
size=2 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 class=OutlookMessageHeader dir=ltr align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> Carl Eastlund
[mailto:carl.eastlund@gmail.com] <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 class=im>
<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></BODY></HTML>