Re: Adding garbage collection to C++

tmb@arolla.idiap.ch (Thomas M. Breuel)
Wed, 12 Aug 1992 16:50:12 GMT

          From comp.compilers

Related articles
Adding garbage collection to C++ Dain.Samples@UC.EDU (1992-08-11)
Re: Adding garbage collection to C++ tmb@arolla.idiap.ch (1992-08-12)
Re: Adding garbage collection to C++ mw@ki.fht-mannheim.de (1992-08-13)
Re: Adding garbage collection to C++ kelvin@kickapoo.cs.iastate.edu (1992-08-13)
Re: Adding garbage collection to C++ fjh@cs.mu.OZ.AU (1992-08-14)
Re: Adding garbage collection to C++ jos@and.nl (1992-08-14)
Re: Adding garbage collection to C++ henry@zoo.toronto.edu (1992-08-14)
Re: Adding garbage collection to C++ bill@amber.ssd.csd.harris.com (1992-08-14)
[9 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: tmb@arolla.idiap.ch (Thomas M. Breuel)
Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle Perceptive)
Date: Wed, 12 Aug 1992 16:50:12 GMT
Keywords: C++, GC
References: 92-08-044



Dain.Samples@UC.EDU writes:


      I have reached the conclusion that only conservative garbage collection
      allows no changes to the existing language [C or C++].


Why have you reached that conclusion? As far as I can tell, ANSI-C and C++
are both fully garbage collectable within the current language standard.
More precisely, I believe that you could compile ANSI-C to portable and
idiomatic CommonLisp (the main difficulty is pointers to automatic
variables).


      I added three additional keywords: collected, heap, and embedded. The
      latter keyword is used to declare pointers that can be used to point into
      objects that are collected, and the other two are used to declare
      collectible objects and allow the programmer to allocate normally gc'd
      objects on the heap.


I don't understand why there is this desire to keep supporting the "usual"
malloc/free style heap allocation once you have garbage collection (the
functions themselves should, of course, continue to exist, with "malloc"
allocating storage and "free" becoming a NOOP).


I have never found malloc/free style storage management to be faster than
a good GC, and as far as I can tell, you never want unreferenced data to
hang around if you have so little memory left that you need to call a
garbage collection. For really daring programmers, you could provide some
primitive "unsafe_free" that returns storage immediately and regardless of
whether there are still references.
Thomas.
[I'd be interested how you trace through unions containing pointers. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.