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-Thread: 103376,147f221051e5a63d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nlpi057.nbdc.sbc.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: memory management in Ada: tedious without GC? Date: Fri, 23 May 2008 19:15:45 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4ddef8bf-b5b1-4d7e-b75b-386cd6c8402c@l17g2000pri.googlegroups.com> <9f2c2db4-d6c1-4cdf-884c-5cbc26ac7701@d1g2000hsg.googlegroups.com> <1qxcw3pphdlek.1jgsfwb7atdmo.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1211584546 7117 192.74.137.71 (23 May 2008 23:15:46 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 23 May 2008 23:15:46 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:sIGJHX/1iy/m+X013Io2qv53Dcg= Xref: g2news1.google.com comp.lang.ada:308 Date: 2008-05-23T19:15:45-04:00 List-Id: "Dmitry A. Kazakov" writes: > On Sun, 18 May 2008 20:50:48 -0700 (PDT), Matthew Heaney wrote: > >> On May 16, 4:42�pm, Maciej Sobczak wrote: >>> >>> In Ada RAII is realized with controlled types. They are severely >>> broken in that they are intrusive in the type hierarchy and they burn >>> the whole budget for implementation inheritance, >> >> No, this is wrong. You can add in Controlled-ness as far down the >> hierarchy as you like, by adding a controlled component. > > This is broken too: > > 1. You don't know exactly the order in which the Finalize of the controlled > component gets called. So if you access the container object over an > access discriminant, that might be already invalid. You know something about the order. Initialize is bottom-up, Finalize is top-down. And when there are access discrims, the order among subling-components is specified by the RM. I would prefer a fully defined order, based on the declaration order. > 2. Similarly, Initialize might be called before the container object is > fully operational. Same here. > 3. Access discriminant would require controlled object to become limited, > so must be the container. Ada 2005 allows access discrims on nonlimited types. > 4. The pattern is exposed to multiple inheritance diamond diagram problem, > when such components are added independently. I don't understand your point here. Could you give an example of the problem? >> Furthermore, if you blow your budget in Ada, then you blow in C++ too, >> since invoking Finalization in Ada is the same as invoking a dtor in C+ > > Well, I suggest that the overhead required in C++ for maintenance virtual > destructors should be lower than one Ada.Finalization. For example it does > not require linked list of objects. Ada's finalization does not require a linked list for stack-allocated objects. It does for heap-allocated ones. > IMO, initialization/finalization hooks shall be definable for all types. - Bob