GNU bug report logs -
#10836
guardians and weak references
Previous Next
Full log
View this message in rfc822 format
Hi,
scheme@(guile-user)> (define x (list 1))
scheme@(guile-user)> (define g (make-guardian))
scheme@(guile-user)> (define p (make-object-property ))
scheme@(guile-user)> (g x)
scheme@(guile-user)> (set! (p x) 100)
$1 = 100
scheme@(guile-user)> (p x)
$2 = 100
scheme@(guile-user)> (set! x #f)
scheme@(guile-user)> (gc) (gc) (gc)
scheme@(guile-user)> (g)
$3 = (1)
scheme@(guile-user)> (p $3)
$4 = #f
scheme@(guile-user)>
The problem: weak references are dropped at finalization time, when
guardians do their magic. If the guardian resuscitates the value, weak
references (like those in the object property) are lost. This is in
contradiction to what the manual says on the subject:
Being an element in a weak vector, a key in a hash table with weak
keys, or a value in a hash table with weak values does not prevent
an object from being returned by a guardian. But as long as an
object can be returned from a guardian it will not be removed from
such a weak vector or hash table. In other words, a weak link
does not prevent an object from being considered collectable, but
being inside a guardian prevents a weak link from being broken.
Andy
--
http://wingolog.org/
This bug report was last modified 13 years and 64 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.