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,97a4ff0c3103bbb6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.glorb.com!peer1.news.newnet.co.uk!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Deallocating list of polymorphic objects? Date: Fri, 01 Dec 2006 06:41:44 +0000 Organization: Pushface Message-ID: References: <1164930027.758923.119740@h54g2000cwb.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1164955302 22766 62.49.19.209 (1 Dec 2006 06:41:42 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Fri, 1 Dec 2006 06:41:42 +0000 (UTC) Cancel-Lock: sha1:OPkPVT7BkVQI0bGWU7JrtVEyCyM= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news2.google.com comp.lang.ada:7769 Date: 2006-12-01T06:41:44+00:00 List-Id: Robert A Duff 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);