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,2ce943dcc1eb3f9c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How to properly clean up an extended, generic structure? References: <44b107b7$0$3629$4d3efbfe@news.sover.net> In-Reply-To: <44b107b7$0$3629$4d3efbfe@news.sover.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.176 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1152474361 12.201.97.176 (Sun, 09 Jul 2006 19:46:01 GMT) NNTP-Posting-Date: Sun, 09 Jul 2006 19:46:01 GMT Date: Sun, 09 Jul 2006 19:46:01 GMT Xref: g2news2.google.com comp.lang.ada:5581 Date: 2006-07-09T19:46:01+00:00 List-Id: Peter C. Chapin wrote: > > Right now I'm working on a generic package that implements splay trees. > My generic parameters look like: > > generic > type Item_Type is private; > with function "<"(L : Item_Type; R : Item_Type) return Boolean; > package Splay_Tree is ... Let me summarize the answers you've received, since some of them only address part of your concern. Your tree should clean up after itself. You don't say if Splay_Tree provides ADTs or an ASM, but in either case controlled types are the way to achieve this (ARM 7.6). Then you don't need to have a visible Destroy operation, and the clients of your package aren't responsible for destroying a tree when it's no longer needed. It's up to the clients of your package to arrange for finalization for the actual associated with Item_Type, if it's needed. Basically, if the actual needs finalization, then it should be a controlled type. If it's a controlled type, then its Finalization procedure will be called when an object ceases to exist, including due to deallocation. -- Jeff Carter "My mind is a raging torrent, flooded with rivulets of thought, cascading into a waterfall of creative alternatives." Blazing Saddles 89