Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!polyslo!ttwang From: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Newsgroups: comp.lang.c++ Subject: Support for movable objects in C++ Message-ID: <1989Sep30.051559.20644@polyslo.CalPoly.EDU> Date: 30 Sep 89 05:15:59 GMT Reply-To: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Distribution: usa Organization: Cal Poly State University -- San Luis Obispo Lines: 29 There is a feature or mis-feature in C++ that makes building a copying garbage collector difficult. Copying garbage collector have two advantages over non-copying garbage collector: (1) Copying garbage collector compacts the heap automatically. (2) Frequently used objects can be copied together for better locality of reference. Copying garbage collector moves an object from one space to another space. Moving and copying are different, because when you move an object to a new location, the object at the old location is discarded. Say that I am in the middle of a member function of object 'obj'. And the collector has decided to move 'obj' to a new location. The problem is that the value of 'this' in the member function will still point to the old location. I propose that C++ be improved, so if one writes: volatile class foo { ... }; The definition of au1_this be changed from foo* to foo**. All the usages of au1_this would be (*au1_this) -> instead of au1_this ->. This way, when I update the value of the master pointer to the new location, the value of 'this' will automatically be correct. -Thomas Wang (Ah so desu ka!) ttwang@polyslo.calpoly.edu