[comp.lang.c++] need garbage collection

sullivan@june.cs.washington.edu (Kevin Sullivan) (02/13/89)

We (a group of 5) are about to implement a fairly substantial system in
C++.  A couple of us have been working for several days now trying to
devise a (preprocessing) scheme that will convert ordinary C++ classes into
garbage collected classes.  Our approach has been to process a class
declaration into two new declarations, one containing the body of the user
defined class plus a reference count, and the other, having the name of the
class the user declared, containing a pointer to an instance of the former.
The idea was that all member class instances would become, in effect,
pointers to heap-based instances.  The assignment operator on these
"wrapper" classes would then be programmed to maintain the reference counts
on assignment.

Unfortunately we have had very little success.   The idea seems simple,
but all of the designs that we have tried so far have interacted very
poorly with aspects of C++, with everything from "this" being passed
implicitly to protected members in the inheritance hierarchy being made
inaccessible by the separation of one class into two.

Have any others solved a problem related to this one?  Any pointers?

Thanks a lot.

-Kevin Sullivan
 Department of Computer Science
 University of Washington
 Seattle, WA.


-- 
--------
Kevin Sullivan, sullivan@cs.washington.edu,
Department of Computer Science, Sieg Hall FR-35, 
University of Washington, Seattle, WA 98195 (206) 543-1695

jima@hplsla.HP.COM (Jim Adcock) (02/15/89)

How about if you get rid of the preprocessor and use the
multiple inheritence of 2.0 to add what's needed for
garbage collection?