From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Hierarchy destruction in Ada
Date: Sun, 12 Dec 2004 16:38:06 +0100
Date: 2004-12-12T16:38:06+01:00 [thread overview]
Message-ID: <v8jhuk8ipeq8.75ssrvd7cik.dlg@40tude.net> (raw)
In-Reply-To: fa59671.0412120718.61093406@posting.google.com
On 12 Dec 2004 07:18:32 -0800, Michael Mounteney wrote:
> Ada 95 provides a mechanism with tagged and type'class to allow
> dynamic dispatch. So if one has:
>
> procedure something (O : basetype'class) is
> begin
> enact (O);
> end something;
>
> then as we all know, with the appropriate redefinitions of enact ()
> for the subtypes of basetype, we have dynamic dispatch. But what
> about deallocation ? I want to declare:
>
> type handle is access all basetype;
You should use class-wide pointers if you want dispatch on them:
type Handle is access all BaseType'Class;
> procedure dispose (ptr : in out handle);
>
> and can't see how to make this deallocate the correct object.
> Obviously, one can dynamically dispatch on ptr.all but it seems
> impossible to solve the complete problem without an unchecked
> conversion. Anyone ?
procedure Dispose is
new Ada.Unchecked_Deallocation (BaseType'Class, Handle);
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2004-12-12 15:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-12 15:18 Hierarchy destruction in Ada Michael Mounteney
2004-12-12 15:38 ` Dmitry A. Kazakov [this message]
2004-12-12 16:52 ` Martin Krischik
2004-12-13 13:41 ` Martin Krischik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox