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!t21g2000yqi.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 06:02:06 -0700 (PDT) Organization: http://groups.google.com Message-ID: <3d991397-94e5-4dd5-8712-a1fe5b1d234c@t21g2000yqi.googlegroups.com> References: <303a64d4-2fdd-47fe-ae4b-3ddf1912cffe@f19g2000yqh.googlegroups.com> <02bb50df-d833-4b08-8f12-a3b10d7dcd78@n8g2000vbb.googlegroups.com> <5dbd97d8-ab49-4316-b531-23b28fc2af7b@k8g2000yqn.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 1244206926 20581 127.0.0.1 (5 Jun 2009 13:02:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 5 Jun 2009 13:02:06 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t21g2000yqi.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:6302 Date: 2009-06-05T06:02:06-07:00 List-Id: On 5 juin, 14:21, Ludovic Brenta wrote: > Pascal Malaise wrote on comp.lang.ada: > > > > > 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; > > That's because P.T is a *private* record extension of > Ada.Finalization.Controlled. Package PP cannot see that P.T derives > from it. > > Solution 1: rename PP to P.P, a child package of P so it can see the > private part of P. > > Solution 2: make P.T a public record extension: > > type T is new Ada.Finalization.Controlled with private; > > But I recommend that you *not* derive P.T from any other type; use a > mixin instead. Making a type controlled is not a good enough reason > for making it tagged. > > -- > Ludovic Brenta. Thank you Ludovic. Solution 2 is fine for me. Concerning your recommendation, I think that the following is compliant, or did I misunderstand something? type T is new Ada.Finalization.Controlled with record I : Integer; end record; end P;