Newsgroups: comp.lang.clos,comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!tank.news.pipex.net!pipex!oleane!jussieu.fr!univ-lyon1.fr!news-rocq.inria.fr!news2.EUnet.fr!news.fnet.fr!ilog!news
From: haible@laplace.ilog (Bruno Haible)
Subject: Re: Weak binding?
In-Reply-To: Simon Beaumont's message of 18 Aug 1995 12:13:06 GMT
Message-ID: <HAIBLE.95Aug21195619@laplace.ilog>
Lines: 37
Sender: news@ilog.fr
Nntp-Posting-Host: laplace
Organization: ILOG S.A., Gentilly, France
References: <41204j$ij3@xenon.bt-sys.bt.co.uk>
Date: 21 Aug 1995 17:56:19 GMT
Xref: glinda.oz.cs.cmu.edu comp.lang.clos:3439 comp.lang.lisp:18904

Simon Beaumont <simon.beaumont@bt-sys.bt.co.uk> writes:

   This serves to highlight a general omission from CL ...
   In other words a weak binding would not increment
   any reference count and additionally would be undone silently
   should the object be gc'd.                           ^^^^^^^^

What is more frequently needed in my experience is the ability to
call a specified hook when an object is about to be GC'ed. Some built-in
like this:

   (ADD-DESTRUCTOR object function)
   has the effect that when the object is about to be garbage-collected,
   the function gets called with object as argument.

Of course, the collection of the object does not take place until the
function has done its job and released the object, so that the next GC
can take it away.

Some extension of this, which can be used to implement weak pointers,
is the following:

   (ADD-DESTRUCTOR object function guardian)
   has the effect that when the object is about to be garbage-collected
   and the guardian has not yet been garbage-collected, then
   the function gets called with object and guardian as arguments.
   If the guardian dies before the object, the function does not get called.


----------------------------------------------------------------------------
Bruno Haible                            net: <haible@ilog.fr>
ILOG S.A.                               tel: +33 1 4908 3585
9, rue de Verdun - BP 85                fax: +33 1 4908 3510
94253 Gentilly Cedex                    url: http://www.ilog.fr/
France                                  url: http://www.ilog.com/


