home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / compiler / 1353 < prev    next >
Encoding:
Internet Message Format  |  1992-08-12  |  2.3 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!ogicse!das-news.harvard.edu!spdcc!iecc!compilers-sender
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.compilers
  4. Subject: Re: Adding garbage collection to C++
  5. Keywords: C++, GC
  6. Message-ID: <92-08-052@comp.compilers>
  7. Date: 12 Aug 92 16:50:12 GMT
  8. References: <92-08-044@comp.compilers>
  9. Sender: compilers-sender@iecc.cambridge.ma.us
  10. Reply-To: tmb@arolla.idiap.ch (Thomas M. Breuel)
  11. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  12.     Perceptive)
  13. Lines: 34
  14. Approved: compilers@iecc.cambridge.ma.us
  15.  
  16.  
  17. Dain.Samples@UC.EDU writes:
  18.  
  19.    I have reached the conclusion that only conservative garbage collection
  20.    allows no changes to the existing language [C or C++].
  21.  
  22. Why have you reached that conclusion? As far as I can tell, ANSI-C and C++
  23. are both fully garbage collectable within the current language standard.
  24. More precisely, I believe that you could compile ANSI-C to portable and
  25. idiomatic CommonLisp (the main difficulty is pointers to automatic
  26. variables).
  27.  
  28.    I added three additional keywords: collected, heap, and embedded.  The
  29.    latter keyword is used to declare pointers that can be used to point into
  30.    objects that are collected, and the other two are used to declare
  31.    collectible objects and allow the programmer to allocate normally gc'd
  32.    objects on the heap.
  33.  
  34. I don't understand why there is this desire to keep supporting the "usual"
  35. malloc/free style heap allocation once you have garbage collection (the
  36. functions themselves should, of course, continue to exist, with "malloc"
  37. allocating storage and "free" becoming a NOOP).
  38.  
  39. I have never found malloc/free style storage management to be faster than
  40. a good GC, and as far as I can tell, you never want unreferenced data to
  41. hang around if you have so little memory left that you need to call a
  42. garbage collection. For really daring programmers, you could provide some
  43. primitive "unsafe_free" that returns storage immediately and regardless of
  44. whether there are still references.
  45.                     Thomas.
  46. [I'd be interested how you trace through unions containing pointers. -John]
  47. -- 
  48. Send compilers articles to compilers@iecc.cambridge.ma.us or
  49. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  50.