From: malaise@magic.fr
Subject: Re: Extending a type and Finalization
Date: Fri, 5 Jun 2009 04:29:36 -0700 (PDT)
Date: 2009-06-05T04:29:36-07:00 [thread overview]
Message-ID: <5dbd97d8-ab49-4316-b531-23b28fc2af7b@k8g2000yqn.googlegroups.com> (raw)
In-Reply-To: 02bb50df-d833-4b08-8f12-a3b10d7dcd78@n8g2000vbb.googlegroups.com
On 4 juin, 21:33, Adam Beneschan <a...@irvine.com> 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;
next prev parent reply other threads:[~2009-06-05 11:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-04 17:45 Extending a type and Finalization pascal.malaise
2009-06-04 18:00 ` Hibou57 (Yannick Duchêne)
2009-06-04 19:33 ` Adam Beneschan
2009-06-04 20:06 ` Dmitry A. Kazakov
2009-06-04 21:18 ` Adam Beneschan
2009-06-05 9:11 ` Dmitry A. Kazakov
2009-06-05 14:48 ` Adam Beneschan
2009-06-05 17:15 ` Dmitry A. Kazakov
2009-06-05 11:29 ` malaise [this message]
2009-06-05 12:21 ` Ludovic Brenta
2009-06-05 13:02 ` malaise
2009-06-05 13:14 ` Ludovic Brenta
2009-06-05 13:32 ` malaise
2009-06-15 6:30 ` AdaMagica
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox