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

Re: Weak Arrays

>mistakes, please)  In ParcPlace's Smalltalk 4.0, they started using a gener-
>ational garbage collector (like Self does) and they included a new type of
>collection called a 'WeakArray,' which they use to solve exactly this type
>of problem.  A weak array can have objects it references garbage collected
>right out from under it.  Weak arrays are also periodically 'informed' when
>their elements die, so that you can do some cleaning up if you want.
>I'm sure this kind of thing isn't all that hard to implement (for all I know,
>Self may already have something like this).  This would be a usefull addition
>to the wish-list, if it isn't there, though..
>		-- Bill
I've just implemented weak referees (WeakArray, WeakOrderedCollection etc)
and finalization (objects with a finalize method get sent finalize when they're
about to die) in my deferred reference counting collector.  It took three days
to do (because I made some stupid mistakes).  If you have a working garbage
collector that you understand and some spare bits in objects (you can usually
shrink the size field) it should be very easy to implement.

I don't like the fact that the ParcPlace scheme
	1. indivisibly links WeakArrays & finalization
	2. only gives you WeakArray

My scheme keeps weak references and finalization orthogonal, and allows
any object with indexed fields to have weak references if it uses a 'weakAtPut'
primitive in place of the standard weakAtPut.

Eliot Miranda,  Lecturer	email:	eliot@dcs.qmw.ac.uk
Department of Computer Science	ARPA:	eliot%dcs.qmw.ac.uk@nsf.ac.uk
Queen Mary Westfield College	UUCP:	eliot@qmw-dcs.uucp
Mile End Road, LONDON E1 4NS	Tel:	071 975 5229 (+44 71 975 5229)
				Fax:	081 980 6533 (+44 81 980 6533)