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 Path: g2news2.google.com!postnews.google.com!r33g2000yqn.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Extending a type and Finalization Date: Fri, 5 Jun 2009 05:21:28 -0700 (PDT) Organization: http://groups.google.com Message-ID: 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: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1244204488 12914 127.0.0.1 (5 Jun 2009 12:21:28 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 5 Jun 2009 12:21:28 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r33g2000yqn.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6299 Date: 2009-06-05T05:21:28-07:00 List-Id: 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 > =A0 type T is tagged private; > private > =A0 type T is new Ada.Finalization.Controlled with record > =A0 =A0 I : Integer; > =A0 end record; > end P; > > with P; > package Pp is > =A0 type Tt is tagged private; > private > =A0 type Tt is new P.T with record > =A0 =A0 Ii : Integer; > =A0 end record; > =A0 overriding procedure Finalize (V : in out Tt); > end Pp; > > package body Pp is > =A0 overriding procedure Finalize (V : in out Tt) is > =A0 begin > =A0 =A0 null; > =A0 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.