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,56131a5c3acc678e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-03 12:08:16 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Question about OO programming in Ada Date: Wed, 3 Dec 2003 14:05:52 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <8urxb.19482$sb4.18182@newsread2.news.pas.earthlink.net> <1792884.HtYz4Yv8lY@linux1.krischik.com> <1070466281.168920@master.nyc.kbcfp.com> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:3113 Date: 2003-12-03T14:05:52-06:00 List-Id: "Hyman Rosen" wrote in message news:1070466281.168920@master.nyc.kbcfp.com... > Dmitry A. Kazakov wrote: > > Of course one could call Unchecked_Deallocation from Finalize > > I understand that Ada permits Finalize to be called multiple times > for an object, so calling Unchecked_Deallocation from Finalize sounds > like a recipe for disaster. 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. This is precisely how Janus/Ada manages complex objects at runtime, so the technique is so familar to me I always find it surprising that it is not obvious to others. Leaving allocation of the object itself to it's owner is necessary in any case: the object may not even have been allocated on the heap, or may be a component of some other object. If you want to manage an access value in Ada 95, you wrap it in a controlled record type and then you can do the allocation/deallocation safely. Randy.