This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: The taming of the before-gc-hook (was Re: Upcoming 1.3.2 release)


Jim Blandy <jimb@red-bean.com> writes:

> The whole question of finalization is a very controversial one.  It's
> difficult to define finalization in a way that gives the finalization
> code enough invariants to establish its correctness while still doing
> something useful.  There are no proposals that make everyone happy.
> Guardians are the cleanest proposal I know of, and seem sufficient for
> most purposes.

I like the weak pointers and finalization proposed in _Stretching the
storage manager: weak pointers and stable names in Haskell_ by Simon
Peyton Jones, Simon Marlow, and Conal Elliott
(http://research.microsoft.com/Users/simonpj/papers/weak.ps.gz).  A
short abstract:

| Every now and then, a user of the Glasgow Haskell Compiler asks for a
| feature that requires specialised support from the storage
| manager. Memo functions, pointer equality, external pointers,
| finalizers, and weak pointers, are all examples.
| 
| We take memo functions as our exemplar because they turn out to be the
| trickiest to support. We present no fewer than four distinct
| mechanisms that are needed to support memo tables, and that (in
| various combinations) satisfy a variety of other needs.
| 
| The resulting set of primitives is undoubtedly powerful and
| useful. Whether they are {\em too} powerful is not yet clear. While
| the focus of our discussion is on Haskell, there is nothing
| Haskell-specific about most of the primitives, which could readily be
| used in other settings.

Of the four mechanisms defined in this paper, unsafePerformIO and
stable names are basically irrelevant to Guile; but the weak pointers
and finalization are directly applicable.  This version lets you do
things guardians don't.  (For example, the above paper points out that
the weak hash table described in Dybvig's guardians paper fails if the
value contains a reference to the key.)

> Also, I don't agree that such hooks are necessary.  Emacs has gotten
> by for years with no such hooks.  Common Lisp doesn't provide them, as
> far as I can see.

I bet you'd find that most implementations of Common Lisp have
finalization, though.

Carl Witty
cwitty@newtonlabs.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]