home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!news
- From: austern@isolde.mti.sgi.com (Matt Austern)
- Newsgroups: comp.lang.c++
- Subject: Re: Why don't you use garbage collection
- Date: 12 Apr 1996 16:56:52 GMT
- Organization: SGI
- Distribution: world
- Message-ID: <AUSTERN.96Apr12095652@isolde.mti.sgi.com>
- References: <316D291F.465D@sto.fdata.se> <1996Apr12.170708.1835@ittpub>
- Reply-To: austern@mti.sgi.com
- NNTP-Posting-Host: isolde.mti.sgi.com
- In-reply-to: wil@ittpub.nl's message of 12 Apr 96 17:07:07 WET
-
- In article <1996Apr12.170708.1835@ittpub> wil@ittpub.nl (Wil Evers) writes:
-
- > In my opinion, this subtle difference is why garbage collection would be
- > appropriate for C, but not for C++. C++ destructors are often used to
- > release other resources than memory. If C++ programmers would get sloppy
- > about deleting their heap objects ("don't worry about deleting it, the
- > collector will do it for you"), we might end up with too many open file
- > descriptors, eternal database locks, forever blocking semaphores and
- > expensive telephone bills.
-
- In C++, I think the most reasonable scenerio is where some objects,
- but not all, are garbage collected. You might, for example, inherit
- from some GC_Base mixin class if you want garbage collection; GC_Base
- would overload operator new to do the appropriate magic. And it's
- entirely reasonable to imagine that you would have to accept some
- restrictions (such as restrictions on destructors) in exchange for
- garbage collection.
-
- In C++ we're used to the idea that heap-allocated and stack-allocated
- objects have different rules. It's not so radical to introduce
- garbage-collected objects as a third category.
- --
- Matt Austern
- SGI: MTI Compilers Group
- austern@isolde.mti.sgi.com
-