home *** CD-ROM | disk | FTP | other *** search
- 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
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: Garbage Collection for C++
- Message-ID: <TMB.92Sep5155705@arolla.idiap.ch>
- Date: 5 Sep 92 19:57:05 GMT
- References: <DAVEG.92Aug17224359@synaptx.synaptics.com> <boehm.714158406@siria>
- <DAVEG.92Aug27002517@synaptx.synaptics.com> <4116@seti.UUCP>
- <boehm.715019515@siria>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 33
- In-reply-to: boehm@parc.xerox.com's message of 28 Aug 92 16:31:55 GMT
-
- In article <boehm.715019515@siria> boehm@parc.xerox.com (Hans Boehm) writes:
-
- This touches on another serious issue with garbage collection in
- C++ that I haven't seen discussed - namely that of programming
- style. [...]
-
- My standard example is a list implementation that consists of a
- "linkable elements" class from which one can inherit (possibly
- multiple times) to get a link field added to one's data structure.
- [...] if you draw some pictures, you can convince yourself that if
- you do enough of this, you are likely to eventually connect
- everything to everything. [...]
-
- I don't think this is an insurmountable problem, since the overhead
- of using cons-cells is probably pretty minimal in reality (and may
- be negative, since you probably didn't really need all those link
- fields at once). But there is a problem with some existing code
- and programming styles here. Interestingly, this seems to be more
- of a problem with C++ code than with C code.
-
- I think this is not a serious problem for two reasons:
-
- (1) Existing code that uses such techniques also contains explicit
- memory management code (i.e., calls to "delete"), so it would
- continue to run as it always did.
-
- (2) Making some data structure into a linked list by inheriting from
- something is rarely "the right thing". I think it was used
- primarily because C++ lacked better type-safe mechanisms. With
- the addition of templates to the language, collection classes will
- be implemented differently and in a more "GC-friendly" way.
-
- Thomas.
-