home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12391 < prev    next >
Encoding:
Text File  |  1992-08-15  |  3.0 KB  |  62 lines

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