bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

weak key hash versus display


From: Kevin Ryde
Subject: weak key hash versus display
Date: Thu, 30 Jan 2003 09:21:15 +1000
User-agent: Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.2 (i386-pc-linux-gnu)

In guile 1.6.1 or the cvs on a recent i386 debian, I noticed that
doing a display of a weak key hash table can seemingly prevent a key
from being garbage collected.  For instance

        (define h (make-weak-key-hash-table 7))

        (define k "mykey")
        (hash-set! h (string-copy k) 12345)

        (display (hash-ref h k)) (newline)
        (display h) (newline)
        (gc)
        (display (hash-ref h k)) (newline)

run with "guile -s foo.scm" produces

        12345
        #wh(() () () () () ((mykey . 12345)) ())
        12345

whereas I might have expected the gc to have collected the entry just
set, making the second hash-ref give #f rather than 12345.  This is
what happens if the (display h) is not present.

I don't really know if this is a bug, or ignorance on my part, but it
seemed more than a little strange.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]