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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ea81945e8b96701b X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: packet type ? Date: 2000/01/18 Message-ID: <862dm6$jr1$1@nnrp1.deja.com>#1/1 X-Deja-AN: 574298995 References: <387F3DD1.485F7C70@icn.siemens.de> <85njs1$3rl$1@nnrp1.deja.com> <38845EBD.6F90845D@icn.siemens.de> X-Http-Proxy: 1.0 x22.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Tue Jan 18 19:08:01 2000 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 2000-01-18T00:00:00+00:00 List-Id: In article <38845EBD.6F90845D@icn.siemens.de>, Alfred Hilscher wrote: > > Ted Dennison wrote: > I think thats not quite the same. Taking the example below, how would > you do this with generics ? > > package type stack is > push (item : in ...); > pop (item : out ...) > end stack > > procedure application is > User_stack : stack; > Supervisor_stack : stack; > Interrupt_stack : stack; > > Any_Stack : access Stack; > begin > ... > Any_Stack := new Stack; -- how do this ??? > ... > end application; The flip answer is I'd download the Booch components. :-) Code wise, I'd do something like this: generic type Element is private; package Stack is type Instance is private; Push (Item : in Element Onto : in out Instance); Pop (Item : out Element; Off_Of : in out Instance); private ... end Stack; It looks like your confusion is based on experience w/ other OO-based languages. In Ada types and packages are completely separate kinds of entities. Packages exist to provide for organizing other things into a single namespace. Types define the data structure of objects. Subprograms are defined within the context of packages, not types or objects. For instance, to call what I created above, first I'd instantiate it with my element type thusly: with Stack; ... procedure Whatever is package Integer_Stack is new Stack (Integer); Then I call push this way: Pushee : Integer := 20; Old_Integers : Integer_Stack.Instance; ... begin Integer_Stack.Push (Item => Pushee, Onto => Old_Integers); -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ Before you buy.