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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,56131a5c3acc678e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-03 12:57:31 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!ash.uu.net!spool.news.uu.net!not-for-mail Date: Wed, 03 Dec 2003 15:57:29 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question about OO programming in Ada References: <8urxb.19482$sb4.18182@newsread2.news.pas.earthlink.net> <1792884.HtYz4Yv8lY@linux1.krischik.com> <1070466281.168920@master.nyc.kbcfp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1070485049.881772@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1070485049 24348 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:3116 Date: 2003-12-03T15:57:29-05:00 List-Id: Randy Brukardt wrote: > Finalize should handle tasks for the components, not the object itself. So, > it is possible (and common) to call U_D on components of the object > (presuming that you have a way to check that it hasn't already been done, a > requirement of all Finalize routines). But you never do memory allocation on > the top-level object. That's not true. In C++, it's not uncommon for objects to have delete this; in their destructors. The technique is used for objects which manage their own lifetimes, and know when it's time to go. Reference counted objects are an example of this - the count is decremented in the destructor, and if it reaches zero, the object deletes itself. No muss, no fuss. The technique does require that a destructor will be called exactly once for an object. C++ guarantees this, Ada does not.