Newsgroups: alt.lang.design,comp.lang.c,comp.lang.c++,comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!pipex!uunet!allegra!alice!ark
From: ark@research.att.com (Andrew Koenig)
Subject: Re: Reference Counting (was Re: Searching Method for Incremental Garbage Collection)
Message-ID: <D08x4q.KM8@research.att.com>
Organization: Software Engineering Research Department
References: <3bgbv6$qmo@network.ucsd.edu> <D03Iwn.Jn5@research.att.com> <3boujh$o0c@news.parc.xerox.com>
Date: Sat, 3 Dec 1994 17:41:13 GMT
Lines: 50
Xref: glinda.oz.cs.cmu.edu comp.lang.c:119111 comp.lang.c++:101494 comp.lang.lisp:15912

In article <3boujh$o0c@news.parc.xerox.com> ellis@parc.xerox.com (John Ellis) writes:
> Andrew Koenig writes:
	
>     Suppose that during execution, the value of one of these
>     cookes becomes unnecessary.  How does the interpreter know
>     that it can delete the corresponding entry from the second
>     associative data structure?  Or can it?

>     One can think of this problem as a kind of meta-garbage-collection.
>     It's hard to see how any programming language can know enough
>     about the application to solve it automatically.

> Such problems are traditionally solved with "weak pointers".  See our
> paper "Safe, Efficient Garbage Collection for C++"

No, the problem I'm describing is not solvable at the GC level.
If you think it is, that means I haven't done a good job of
describing it.  This is doubly likely because you aren't the only
person who has misunderstood it.  Sorry about that.

So let me try again, this time in slightly more general terms.

Suppose you have a program that deals with three types called,
say, R, S, and T, and two associative arrays:

	Map<R, S> m1;
	Map<S, T> m2;

Then if r is a value of type R, m2[m1[r]] is a value of type T
that is obtained by looking up r is m1 and then looking up the result
of that in m2.

Suppose further that m2 is only used in this way.  Then whenever
we delete a value from m1, we *might* be able to delete a value from
m2 as well.  In particular, m1[r] == s and we are deleting m1[r],
then we can delete m2[s] as well, PROVIDED THAT NO OTHER ELEMENT OF
m1 HAS THE VALUE s.

My point is that this is really a memory management problem, but
it is couched in terms that no programming language will `recognize'
as being a memory management problem.  In effect, I am using values of
type S as pointers, even though in principle S could be any type at all.

The point I was trying to make is that even in a language with automatic
memory management, problems of this sort can come up.  In effect I
have introduced another level of abstraction beyond what is usually
found as part of programming languages.
-- 
				--Andrew Koenig
				  ark@research.att.com
