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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c6e5a27ff403a94d,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-22 20:41:59 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn14feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc53.POSTED!not-for-mail From: Stapler Subject: Package instantiation and automatic de-allocation. Newsgroups: comp.lang.ada User-Agent: Pan/0.11.2 (Unix) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Comment-To: ALL Message-ID: NNTP-Posting-Host: 12.241.145.39 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc53 1040618525 12.241.145.39 (Mon, 23 Dec 2002 04:42:05 GMT) NNTP-Posting-Date: Mon, 23 Dec 2002 04:42:05 GMT Organization: AT&T Broadband Date: Mon, 23 Dec 2002 04:42:05 GMT Xref: archiver1.google.com comp.lang.ada:32218 Date: 2002-12-23T04:42:05+00:00 List-Id: Alright, I'm running into a bit of wall here. I can get my package to work, but I cant get it to work the way I want it to. Basically, as I understand it, if I declare something such as package foo is new generic_stack(Size, Integer); Then it wont be de-allocated when it goes out of scope(like at the end of a declare block) like it should be. This is assuming I've declared it in the declare section of the declare block. Further more I can't "use" generic_stack and then declare a variable such as My_Stack : Stack(Size, Integer); because language rules wont allow me to "use" a generic_package. I've tried all sorts of things... with gen_stack; My_Stack : gen_stack.Stack(Size, Integer); My_Stack : new gen_stack.Stack(Size, Integer); My_Stack : Blah blah blah. Heres the package spec, any pointers would be helpful. generic Size : Positive; type Item is private; package gen_stack is Stack_Overflow : exception; Stack_Underflow : exception; procedure Push( X : in Item); function Pop return Item; function Is_Full return Boolean; -- These functions simply export function Is_Empty return Boolean;-- The Full, Empty fields of the stack. private subtype Stack_range is positive range 1..Size; type Item_array is array(positive range 1..Size) of Item; type Stack is limited record Elements : Item_Array; Top : Stack_range; Full, Empty : Boolean; end record; end gen_stack; Basically I want to figure out how to instantiate this within a program without having to dick with Unchecked_Deallocation. i.e. I want to be able to assume that it will be de-allocated at then "end" of a declare block, whether a procedure or an inline "declare" region. Currently I have to go ... package My_Stack is new gen_stack(Size, Foo_Type); Any pointers would be appreciated. Stapler