From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,19140af19dfa6e01 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-12 01:36:27 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!npeer.de.kpn-eurorings.net!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Ada 0Y plans for garbage collection? Date: Fri, 12 Sep 2003 10:43:50 +0200 Message-ID: References: <1127954.kcBZz6amlf@linux1.krischik.com> <3F60E747.40805@attbi.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1063355785 23358903 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:42404 Date: 2003-09-12T10:43:50+02:00 List-Id: On Thu, 11 Sep 2003 21:21:21 GMT, "Robert I. Eachus" wrote: >>>I still think the way it was done in Modula-3 gives you the best of >>>both worlds. If you want garbage collection, you allocate from a >>>different pool. If you don't want it you don't use it, and there is no >>>overhead. >> >> Well, you can have this allready at least with GNAT. See >> http://www.ada.krischik.com for details. > >Exactly. And if you read the documentation there, you eventually >conclude that a garbage collected pool for Ada implementations may seem >like a good thing, but it creates more issues than it solves. It can be >done, and it has been done. But in practice building reference counts >into types which need garbage collection gives you much better control >over finalization. Absolutely! (I saw no single real-life example, where automatic GC were a solution of choice) >And yes, I know that there are general graph structures where reference >counts don't work. I also know that in practice most such general >graphs can be constructed with structural pointers and general pointers >so that the structural pointers define a tree and nodes not in the tree >should be reclaimed. You could say that doing that is a lot of extra work. Actually, it is not so much work. I did it many times. --------- But reference counting could be made much more easy and attractive if smart pointers have more light-weighted implementation than controlled types in generic packages. There are too many problems with that: 1. Controlled types are slow. 2. They have by-reference semantics, which is a source of nasty pitfalls. 3. They are not transparent as true access types are. So you have to define a plethora of proxy methods and take a great care to maintain them when the pointed type gets changed. It is awful and unsafe. 4. Derived types are not supported. That is, there is no way to make a smart pointer to a derived type class a member of the class of smart pointers pointing to the base type class. One need to support two parallel type hierarchies which is absolutely impossible with generics. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de