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: 103376,672558c47d86bb1d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Hierarchy destruction in Ada Date: Sun, 12 Dec 2004 16:38:06 +0100 Organization: cbb software GmbH Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: individual.net KDoNWNPlZX+XMO+Ui31oqghx9dcNd6wNRgRSS5Ras1m0ydMR0= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:6900 Date: 2004-12-12T16:38:06+01:00 List-Id: 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