home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mole-end!mat
- From: mat@mole-end.matawan.nj.us
- Subject: Re: Garbage Collection for C++
- Message-ID: <1992Aug16.075804.27511@mole-end.matawan.nj.us>
- Organization: :
- References: <1992Aug6.014619.2111@ucc.su.OZ.AU> <TMB.92Aug14130323@arolla.idiap.ch>
- Date: Sun, 16 Aug 1992 07:58:04 GMT
- Lines: 51
-
- In article <TMB.92Aug14130323@arolla.idiap.ch>, tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
- > In article <1992Aug14.021547.15215@news.mentorg.com> bcannard@hppcb36.mentorg.com (Bob Cannard @ PCB x5565) writes:
-
- > In article <DAVEG.92Aug13025629@synaptx.synaptics.com>, daveg@synaptics.com (Dave Gillespie) writes:
- > |> Couldn't we get away with having a garbage collector that didn't
- > |> need pointers to be declared `GC'?
-
- > I can't see that this is viable given the basic constraints on C++: among
- > other things, those who don't want GC shouldn't have to suffer the hits.
- >
- > What "hits"? In all the cases that I have looked at, the GC overhead
- > has been _smaller_ than the overhead of explicit memory management in
- > C++. ...
-
- > Based on my experience, I would turn your statement around and say:
- > "those of us who want GC shouldn't have to suffer the inefficiencies
- > of not having it".
-
- The real problem with GC is that it is based on a particular model of
- how a programming language represents something. That model states
- that the _value_ of something is all that matters; once the value
- disappears, the identity means nothing. On the other hand, C++, with
- defined lifetimes for objects, declares that the object identity is
- part of the model of computation.
-
- To put it differently, when does the destructor for a GC'd object get
- called? What happens if the GC'd object's destructor makes a call that
- has an effect outside the system? In other words, what happens to
- relationships between the objects in the system and the world outside?
-
- A great deal of a program's information is stored in the relationships
- between things, and not just in their values. A GC'able language has
- a certain semantic restriction: you will never use the actual object
- (i.e. object-in-memory as C and C++ define the word) identity to represent
- something. If you have a reference to another object, it is because you
- are interested in the value stored there, not in the object identity
- itself. Once the value is no longer accessible, the object identity is
- worthless.
-
- C++ doesn't make this assumption. Some data structures that are written
- in C++ may, and GC may be suitable for those data structures. But the
- suitability of those data structures to GC shouldn't be mistaken for
- the suitability of C++ for GC. C++ doesn't assume or demand GC'able
- semantics in its representations. In fact, it assumes _and_ demands
- semantics that are contrary to GC (management of object lifetime)--but
- it doesn't force these semantics on every representation.
- --
- (This man's opinions are his own.)
- From mole-end Mark Terribile
-
- mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ
-