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,4f0b59438ce4c5b9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-19 09:44:38 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.stueberl.de!newspeer1-gui.server.ntli.net!ntli.net!newsfep4-winn.server.ntli.net.POSTED!53ab2750!not-for-mail From: chris User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031014 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Deallocation & Tagged Types References: <5Fhkb.3195$KA5.27417@newsfep4-glfd.server.ntli.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Sun, 19 Oct 2003 17:50:46 +0100 NNTP-Posting-Host: 81.98.236.129 X-Complaints-To: abuse@ntlworld.com X-Trace: newsfep4-winn.server.ntli.net 1066581878 81.98.236.129 (Sun, 19 Oct 2003 17:44:38 BST) NNTP-Posting-Date: Sun, 19 Oct 2003 17:44:38 BST Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:1143 Date: 2003-10-19T17:50:46+01:00 List-Id: Dmitry A. Kazakov wrote: > > Same as with any other access type (except an access to subprogram, mind you > (:-)): > > function Free is > new Ada.Unchecked_Deallocation (Vehicle'Class, Vehicle_Access); > > Free (V.Actual); > -- Kills V.Actual and sets V.Actual to null, > -- or does nothing if V.Actual is already null Interesting... I didn't know you could do that. I had tried just Vehicle not Vehicle'Class but that was obviously wrong. I must remember that you can instantiate generics like that. > Note that Free releases a _class-wide_ object. So it first dispatches to > whatever language-defined finalization is required (for a controlled type > it is Finalize) then it deallocates the memory. > > BTW, it is better to make Vehicle and Proxy controlled and name Destroy > "Finalize", which will be then called implicitly, and note always the right > one. It need not to be abstract because the type Vehicle is already > abstract, so no harm can be done anyway. In the code they are Controlled and the Finalization routine does tidy up, but it too got stuck at getting rid of V.Actual access variable. Now it can go away too. What is the benefit of making "destroy", "finalize"? Thanks, Chris