From: Simon Wright <simon@pushface.org>
Subject: Re: Deallocating list of polymorphic objects?
Date: Fri, 01 Dec 2006 06:41:44 +0000
Date: 2006-12-01T06:41:44+00:00 [thread overview]
Message-ID: <m2ejrk9kyf.fsf@grendel.local> (raw)
In-Reply-To: wcc3b80v5u4.fsf@shell01.TheWorld.com
Robert A Duff <bobduff@shell01.TheWorld.com> writes:
> But, to be safe, you should ensure that the result type of each
> "new" is the same as the type passed to Unchecked_Deallocation.
In the Ada95 context I've come across this most (a procedure takes
access-to-classwide, callers allocate locally) I started off thinking
of something like
type Bar is tagged private;
type Bar_P is access Bar'Class;
type Foo is new Bar with private;
type Foo_P is access Foo;
...
F : Foo_P := new Foo'(...);
BC : Bar_P := F.all'Access;
...
Free (BC);
but remembering Bill Taylor's remarks about splattering your code with
".all'Access", and so as to avoid declarations like Foo_P, ended up
with
type Bar is tagged private;
type Bar_P is access Bar'Class;
type Foo is new Bar with private;
...
BC : Bar_P := new Foo'(...);
F : Foo renames Foo (BC.all);
...
Free (BC);
next prev parent reply other threads:[~2006-12-01 6:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-30 23:40 Deallocating list of polymorphic objects? Michael Rohan
2006-12-01 0:05 ` Robert A Duff
2006-12-01 6:41 ` Simon Wright [this message]
2006-12-01 1:24 ` Randy Brukardt
2006-12-01 8:57 ` Maciej Sobczak
2006-12-01 12:33 ` Matthew Heaney
2006-12-01 13:05 ` Maciej Sobczak
2006-12-01 14:56 ` Matthew Heaney
2006-12-01 19:03 ` Georg Bauhaus
2006-12-01 3:52 ` Matthew Heaney
2006-12-01 4:11 ` Matthew Heaney
2006-12-01 6:12 ` Michael Rohan
2006-12-01 12:40 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox