home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13330 < prev    next >
Encoding:
Internet Message Format  |  1992-09-07  |  2.2 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!olivea!mintaka.lcs.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Garbage Collection for C++
  5. Message-ID: <TMB.92Sep5155705@arolla.idiap.ch>
  6. Date: 5 Sep 92 19:57:05 GMT
  7. References: <DAVEG.92Aug17224359@synaptx.synaptics.com> <boehm.714158406@siria>
  8.     <DAVEG.92Aug27002517@synaptx.synaptics.com> <4116@seti.UUCP>
  9.     <boehm.715019515@siria>
  10. Sender: news@ai.mit.edu
  11. Reply-To: tmb@idiap.ch
  12. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  13.     Perceptive)
  14. Lines: 33
  15. In-reply-to: boehm@parc.xerox.com's message of 28 Aug 92 16:31:55 GMT
  16.  
  17. In article <boehm.715019515@siria> boehm@parc.xerox.com (Hans Boehm) writes:
  18.  
  19.    This touches on another serious issue with garbage collection in
  20.    C++ that I haven't seen discussed - namely that of programming
  21.    style. [...]
  22.  
  23.    My standard example is a list implementation that consists of a
  24.    "linkable elements" class from which one can inherit (possibly
  25.    multiple times) to get a link field added to one's data structure.
  26.    [...]  if you draw some pictures, you can convince yourself that if
  27.    you do enough of this, you are likely to eventually connect
  28.    everything to everything. [...]
  29.  
  30.    I don't think this is an insurmountable problem, since the overhead
  31.    of using cons-cells is probably pretty minimal in reality (and may
  32.    be negative, since you probably didn't really need all those link
  33.    fields at once).  But there is a problem with some existing code
  34.    and programming styles here.  Interestingly, this seems to be more
  35.    of a problem with C++ code than with C code.
  36.  
  37. I think this is not a serious problem for two reasons:
  38.  
  39. (1) Existing code that uses such techniques also contains explicit
  40.     memory management code (i.e., calls to "delete"), so it would
  41.     continue to run as it always did.
  42.  
  43. (2) Making some data structure into a linked list by inheriting from
  44.     something is rarely "the right thing". I think it was used
  45.     primarily because C++ lacked better type-safe mechanisms.  With
  46.     the addition of templates to the language, collection classes will
  47.     be implemented differently and in a more "GC-friendly" way.
  48.  
  49.                     Thomas.
  50.