Newsgroups: comp.lang.clos,comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!nntp.sei.cmu.edu!news.psc.edu!hudson.lm.com!news.math.psu.edu!news.cac.psu.edu!newsserver.jvnc.net!newsserver2.jvnc.net!howland.reston.ans.net!ix.netcom.com!netcom.com!NewsWatcher!user
From: hbaker@netcom.com (Henry Baker)
Subject: Re: Weak binding?
Message-ID: <hbaker-1808950904590001@192.0.2.1>
Sender: hbaker@netcom18.netcom.com
Organization: nil organization
References: <41204j$ij3@xenon.bt-sys.bt.co.uk>
Date: Fri, 18 Aug 1995 17:04:59 GMT
Lines: 46
Xref: glinda.oz.cs.cmu.edu comp.lang.clos:3405 comp.lang.lisp:18836

In article <41204j$ij3@xenon.bt-sys.bt.co.uk>, Simon Beaumont
<simon.beaumont@bt-sys.bt.co.uk> wrote:

> This is an old one but I haven't been able to find a solution and
> have no references to find the state of the art.
> 
> To explain:
> An example of a common requirement in CLOS programs
> is to memoize instances of a class (usally in the class metaobject);
> since this usually requires stuffing objects onto a list in the class
> these objects are thus prevented from otherwise being gc'd. 
> 
> This serves to highlight a general omission from CL, that is the
> notion of weak binding, what I mean here is a binding that may
> be undone (unbound) automatically and the relevant object then
> becoming eligible for gc'ing should only other weak or no other
> bindings exist. In other words a weak binding would not increment
> any reference count and additionally would be undone silently
> should the object be gc'd.
> 
> The question is: Is there a way to implement this portably
> in common-lisp? My gut feel for this is no, otherwise I guess
> I'd be using it and not posting here. I suppose various 
> implementations might offer some access to underlying gc controls.
> I have often thought that lisp should offer some control over
> storage parameters on a per object basis, maybe this would be
> an opportunity to open up lisp storage managment via a MOP or
> whatever.

I'm not aware of any _portable_ way to do this.  Maclisp had
'non-gc'd' arrays, which were used for implementing 'weak pointers'
for AI programs.  These required conspiring with a 'gc-daemon', which
was a user-level program that ran at the end of every gc.
I have been told that MIT Multilisp/Multischeme had some form of weak
pointer capability as well.

The notion of a 'weak symbol' in linking loaders is essentially identical
to the notion of a weak pointer.  A weak symbol is incapable of loading
a subroutine from a library on its own, but if the subroutine is loaded
via a 'strong symbol', then the weak symbol will be appropriately updated.
Otherwise, it is zero.  'Weak symbols' are used in at least Unix SVR4, and
go back perhaps 30 years to early IBM linking loaders.

-- 
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html
