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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,155b49c9f46f66ec X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-29 07:11:28 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!paladin.american.edu!auvm!J64.STRATCOM.AF.MIL!BennettC Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU Newsgroups: comp.lang.ada Encoding: 56 TEXT X-Mailer: Microsoft Mail V3.0 Message-ID: <2EDB5E6E@SMTPGATE2.STRATCOM.AF.MIL> Date: Tue, 29 Nov 1994 09:04:00 PST Sender: Ada programming language From: "Bennett, Chip (KTR) ~U" Subject: Re: don't understand packages vs. objects/classes Date: 1994-11-29T09:04:00-08:00 List-Id: "Andrew E. Caldwell" wrote: > It seems to me (in my VERY limited Ada knowledge) that packages are > like classes for OOP purposes. They have the features of data hiding, and > binding procedures with data, hiding implementation, etc. But, how > do you get more than one of them in a procedure/function. I'm having a hard time understanding why we are compelled to keep giving you generics as the solution to your question. It's sort of like using an elephant gun to kill an ant. It seemed to me that your question had more to do with how to get many stacks, not how to get stacks of different types. If you're only implementing stacks of integers, you need only declare a abstract stack type that is instantiated a number of times (for each stack), and managed by the push and pop routines in the same package. A possible spec would be: package IntStacks is type Stack is private; procedure Push (S : in out Stack; Item : in Integer); function Pop (S : in out Stack) return Integer; private type Stack is ... -- actual representation -- i.e. array of integers, -- linked list of integers, etc. end Stacks; You might use this stack type in the following way: with IntStacks; use IntStacks; procedure YourProg is Stack1 : Stack; Stack2 : Stack; begin Push (Stack1, 34); Push (Stack2, 12); end YourProg; Generics is a beautiful concept, way ahead of its time in 1983, but we sometimes have a tendency to use them in every answer. They give a great deal of flexibility, but are not needed in every solution. ***************************************************************** * Chip Bennett, GDE Systems Inc | BennettC@j64.stratcom.af.mil * * USSTRATCOM/J64213 | Voice (402)294-7360 * * 901 SAC Blvd, Suite 2B24 | FAX (402)294-7912 * * Offutt AFB, NE 68113-6600 | Proud member of Team Ada * * Opinions expressed here are my own _so_, TTFWTW * *****************************************************************