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: a07f3367d7,2c1aef7e0a2350d1 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!k8g2000yqn.googlegroups.com!not-for-mail From: malaise@magic.fr Newsgroups: comp.lang.ada Subject: Re: Extending a type and Finalization Date: Fri, 5 Jun 2009 04:29:36 -0700 (PDT) Organization: http://groups.google.com Message-ID: <5dbd97d8-ab49-4316-b531-23b28fc2af7b@k8g2000yqn.googlegroups.com> References: <303a64d4-2fdd-47fe-ae4b-3ddf1912cffe@f19g2000yqh.googlegroups.com> <02bb50df-d833-4b08-8f12-a3b10d7dcd78@n8g2000vbb.googlegroups.com> NNTP-Posting-Host: 192.54.144.229 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1244201377 3247 127.0.0.1 (5 Jun 2009 11:29:37 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 5 Jun 2009 11:29:37 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k8g2000yqn.googlegroups.com; posting-host=192.54.144.229; posting-account=52eKqgoAAADWCuSusv9knR2f_28-NAV2 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.0.6) Gecko/20060728 (CK-Thales) Firefox/1.5.0.6,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6298 Date: 2009-06-05T04:29:36-07:00 List-Id: On 4 juin, 21:33, Adam Beneschan wrote: > In addition to making an individual component a Limited_Controlled > type, you can use trickery using access discriminants to allow the > Initialize and Finalize routines to access the entire record. I have done that and it works (at least it compiles). Thank's. > However, if it's possible to go back and change P.T to make it a type > derived from Limited_Controlled, that would be preferable, I think. > The default Initialize and Finalize routines will be null, so doing > this shouldn't change the semantics of the rest of the program any, > although it will add some overhead. I face a problem when doing that, despite it should be straightforward!. I declare P.T as "new Ada.Finalization.Controlled with record ..." and I don't define Finalize for it. Then in Pp I declare Tt as "new P.T with record ..." and I declare an overriding procedure Finalize (V : in out Tt) and its body in Pp body. It does not compile, with error: 'subprogram "Finalize" is not overriding' Same if I define in P a Finalize for T. Any idea? ------------------------------ with Ada.Finalization; package P is type T is tagged private; private type T is new Ada.Finalization.Controlled with record I : Integer; end record; end P; with P; package Pp is type Tt is tagged private; private type Tt is new P.T with record Ii : Integer; end record; overriding procedure Finalize (V : in out Tt); end Pp; package body Pp is overriding procedure Finalize (V : in out Tt) is begin null; end Finalize; end Pp;