guile-devel
[Top][All Lists]
Advanced

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

Re: ‘set-cdr!’ and weak-cdr pairs


From: Andy Wingo
Subject: Re: ‘set-cdr!’ and weak-cdr pairs
Date: Sun, 27 Mar 2011 13:22:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

On Sun 13 Mar 2011 16:25, address@hidden (Ludovic Courtès) writes:

> The problem is that ‘hash-create-handle!’ above created a weak-cdr
> pair—i.e., a pair whose cdr is /not/ scanned for pointers—but ‘set-cdr!’
> did not register a disappearing link from O to K+V.  Consequently, O
> eventually gets collected, but K+V remains; the storage of O then gets
> reused, and the cdr of K+V ends up containing either an unrelated or >an
> invalid Scheme object.

Given that we don't expose weak-pair constructors or accessors to
Scheme, we should not expose weak pairs to Scheme.  What do you think
about making it an error to hash-create-handle! on a weak table?  That
way you never expose a weak pair to Scheme.  It does appear possible to
discriminate in C between calls to create-handle! that occur due to ref
/ set! and those that are called explicitly.

Also that would free up our implementation to use something other than
weak pairs for weak hash tables.  In particular, I think first-class
weak references are not a bad idea, as Chez Scheme does.

WDYT?

Andy
-- 
http://wingolog.org/



reply via email to

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