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,ea81945e8b96701b X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: packet type ? Date: 2000/01/18 Message-ID: #1/1 X-Deja-AN: 574271145 References: <387F3DD1.485F7C70@icn.siemens.de> <85njs1$3rl$1@nnrp1.deja.com> <38845EBD.6F90845D@icn.siemens.de> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: nntp1.ba.best.com 948212719 203 206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-01-18T00:00:00+00:00 List-Id: On Tue, 18 Jan 2000, Alfred Hilscher wrote: > Ted Dennison wrote: > > > > > question is obsolete. What I'm looking for is something like a > > "packege > > > type" (similar to "task type"). What I want do is something like this: > > > > > Any suggestions how to do this ? > > > > That's what generics with package formal parameters are for. > > > 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; Packages are not first class entities in Ada. They cannot be assigned to variables or passed as function arguments. The closest you get is as T.E.D. suggested, by using generic formal package parameters which give you a small language for combining the packages. What is there that you wished to do with first class packages that you couldn't do equally nicely with plain old ADTs, maybe even using tagged types to be fancy :-). The stack example is easily programmed that way. -- Brian