unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#9900: Using a guardian on a value in a weak hash
@ 2011-10-28 20:42 Ian Price
  2011-10-29 17:42 ` Stefan Israelsson Tampe
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Ian Price @ 2011-10-28 20:42 UTC (permalink / raw)
  To: 9900


Hi guilers,

If I 'guard' a value, and store it in a weak-key hashtable, then it
doesn't appear in the guardian even after it is removed from the
weak-hash by a garbage collection. Note, this only happens in a
_script_, and will work fine in a REPL (you should only need two GCs,
one for the weak hash, and one for the now free value).
e.g.


(define guardian (make-guardian))
(define finalizer-table (make-weak-key-hash-table))

(let ((f (lambda () (display "test\n"))))
  (guardian f)
  (hashq-set! finalizer-table (cons #f #f) f)
  #f)

(write finalizer-table)
(newline)

(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)

(write finalizer-table)
(newline)

(write (guardian))
(newline)


will produce the output


[ian@Kagami guile]$ guile -s /tmp/gcbug.scm 
#<weak−key−hash−table 1/31>
#<weak−key−hash−table 0/31>
#f
[ian@Kagami guile]$ 

-- 
Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"






^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-12-18 23:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-28 20:42 bug#9900: Using a guardian on a value in a weak hash Ian Price
2011-10-29 17:42 ` Stefan Israelsson Tampe
2011-10-29 18:51   ` Ian Price
2011-10-30 13:52 ` bug#9900: local vars not cleaned Stefan Israelsson Tampe
2011-10-30 18:49   ` Stefan Israelsson Tampe
2011-11-01  0:20     ` Ludovic Courtès
2011-11-01 19:53       ` Andy Wingo
2011-11-09 22:47 ` bug#9900: Using a guardian on a value in a weak hash Andy Wingo
2011-12-14 21:49   ` Ludovic Courtès
2011-12-15 21:55     ` Andy Wingo
2011-12-18 23:38       ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).