bug-guile
[Top][All Lists]
Advanced

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

bug#10836: guardians and weak references


From: Andy Wingo
Subject: bug#10836: guardians and weak references
Date: Fri, 17 Feb 2012 15:52:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

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/





reply via email to

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