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,de1c23707584fc3c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-22 14:33:00 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsgate.duke.edu!newsfeed!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: virtual destructors Date: 22 Apr 2003 17:32:59 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1051047179 8824 199.172.62.241 (22 Apr 2003 21:32:59 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 22 Apr 2003 21:32:59 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:36375 Date: 2003-04-22T17:32:59-04:00 List-Id: tmoran@acm.org writes: > > Another question: are there any advantages in using > > Ada.Finalization for objects that will always be dynamically > > allocated/deallocated over simply declaring a Dispose procedure, > The compiler will make sure Finalize is called, whereas the programmer > will sooner or later forget to call Dispose. But the Finalize is just doing some Unchecked_Deallocations (according to the OP), so it doesn't really matter. If you forget to Dispose, then it will Dispose just before program exit, which is not really useful. If the Finalize were doing something important, then yes, the Ada implementation makes sure it happens. But for library-level access types (which is 99.9% of all access types, I suspect), it happens very late in the game if you don't explicitly Dispose. I think the truth is that finalization is much more useful for stack objects than for heap objects. In Java, where everything's a heap object, and deallocation is done by GC, finalization (quite a complex feature) is nigh unto useless, which is rather a shame. You can't do most of the useful tricks that Ada and C++ allow, like locking/unlocking a resource via finalization. - Bob