comp.lang.ada
 help / color / mirror / Atom feed
From: "kat-Zygfryd" <6667@wp.pl>
Subject: Re: virtual destructors
Date: Tue, 22 Apr 2003 16:56:03 +0200
Date: 2003-04-22T14:56:09+00:00	[thread overview]
Message-ID: <b83l69$7bk$1@news.onet.pl> (raw)
In-Reply-To: u1xzuehed.fsf@nasa.gov

"Stephen Leake" <Stephe.Leake@nasa.gov> wrote in message
news:u1xzuehed.fsf@nasa.gov...
> The nearest equivalent of C++ destructors is achieved by deriving from
> a type declared in Ada.Finalization. Note that it is not a very close
> equivalent, so to be really helpful, we need to know in a larger sense
> what you are trying to do.
>
> --
> -- Stephe

I want to have destructors working on access' to class wide types,
so that when passed a variable, an actual type destructor was
called, not a one overloaded for the specific type.

example:

type Base is tagged record ... end record;
type PBase is access Base;
type CBase is access Base'Class;

type Derived is new Base with record ... end record;
type PDerived is access Derived;
type CDerived is access Derived'Class;

procedure Free is new Ada.Unchecked_Deallocation(Base,PBase);
procedure Free is new Ada.Unchecked_Deallocation(Derived,PDerived);

procedure Dispose(self: in out CBase) is
begin
   --?
   self := null;
end Dispose;

procedure Dispose(self: in out CDerived) is
begin
    -- ?
   self := null;
end Dispose;

declare
    B: CBase := new Base;
    D: CBase := new Derived;
begin
    Dispose(B);
    Dispose(D);
end;

I want both Disposes to work as they should, what should I fill them with?

Zygfryd





  reply	other threads:[~2003-04-22 14:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-22 14:18 virtual destructors kat-Zygfryd
2003-04-22 14:27 ` Stephen Leake
2003-04-22 14:56   ` kat-Zygfryd [this message]
2003-04-22 15:45     ` kat-Zygfryd
2003-04-22 16:34       ` tmoran
2003-04-22 21:32         ` Robert A Duff
2003-04-22 17:18       ` Stephen Leake
2003-04-22 16:34         ` Simon Wright
2003-04-22 19:57           ` Stephen Leake
2003-04-22 20:19             ` Simon Wright
2003-04-22 21:23             ` Robert A Duff
2003-04-23 15:16         ` Matthew Heaney
2003-04-22 17:31       ` virtual destructors - doesn't seem to work kat-Zygfryd
2003-04-22 17:32         ` Simon Wright
2003-04-22 17:33     ` virtual destructors Matthew Heaney
2003-04-22 17:28 ` Matthew Heaney
2003-04-22 17:40   ` kat-Zygfryd
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox