home *** CD-ROM | disk | FTP | other *** search
- 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
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.compilers
- Subject: Re: Adding garbage collection to C++
- Keywords: C++, GC
- Message-ID: <92-08-052@comp.compilers>
- Date: 12 Aug 92 16:50:12 GMT
- References: <92-08-044@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Reply-To: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 34
- Approved: compilers@iecc.cambridge.ma.us
-
-
- 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]
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-