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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,73e5f80245e6297 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Chunks of finalized Date: 1997/10/04 Message-ID: #1/1 X-Deja-AN: 277830941 References: <6129sn$n91$1@goanna.cs.rmit.edu.au> <3434F45A.37ED@gsfc.nasa.gov> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-10-04T00:00:00+00:00 List-Id: In article <3434F45A.37ED@gsfc.nasa.gov>, Stephen Leake wrote: >Do you want to call Finalize on the elements that have been Popped? = That's presumably the issue. These elements might be hanging on to some expensive resource, and he wants to free that resource as soon as possible -- not waiting for a whole chunk to be deallocated. >... Another way is to assign another object to the >stack slot, which will be done by the next Push. Aha! Thank you. Why wait until the next Push (which might be a long time, or never)? Inside the generic, you could declare: type Stack_Element_Holder(Present: Boolean := False) is record case Present is when False => null; when True => The_Element: Stack_Element_Type; end case; end record; And then build the stack out of arrays of these things. Then, whenever you Pop, assign a "Stack_Element_Holder'(Present => False)" into the vacated slot. I think this achieves what the original poster wanted -- it will call Finalize on The_Element (if its controlled), and it will also call Finalize on all controlled subcomponents of The_Element. And there's no need to pass in an extra finalization operation, nor to handle subcomponents by hand. It costs an extra Boolean component for every stack element, though. - Bob