From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 16 Sep 92 00:17:18 GMT From: agate!linus!think.com!yale.edu!spool.mu.edu!caen!uakari.primate.wisc.edu! aplcen.apl.jhu.edu!ddsdx2.jhuapl.edu!dlc@ucbvax.Berkeley.EDU (Dave Collard x74 68) Subject: Re: Novice Question On Generics Message-ID: <1992Sep16.001718.12811@aplcen.apl.jhu.edu> List-Id: In <1992Sep15.184345.12197@saifr00.cfsat.honeywell.com> lam@saifr00.cfsat.honey well.com (Josh Lam) writes: >I have a generic package Queue that has the function enqueue. >This generic package is 'with' into two packages A and B that looks >like: >with Queue with Queue >package A is package B is > ... ... >Question: >Is there a way to write a generic procedure Run_Proc that the two packages >A and B can use? Note that the user *does not* need to know my_QA generic type Queue_Item is private; with procedure Enqueue(Item : in Queue_Item); procedure Run_Proc is begin Enqueue(Queue_Item); end Run_Proc; with Run_Proc; with Run_Proc; with Queue; with Queue; package A is package B is type A_Rec is record... type B_Rec is record... end record; end record; package A_Queue is new Queue(A_Rec); package B_Queue is new Queue(B_Rec); procedure A_Run_Proc is new package B_Run_Proc is new Run_Proc(A_Rec, A_Queue.Enqueue); Run_Proc(B_Rec,B_Queue.Enqueue); ... ... end A; end B; BUT it is a pain *if* Run_Proc uses many procedures from Queue. Each routine from the queue package needs to be a generic parameter to the Run_Proc (generic) routine. In Ada 9X, you will be able to instantiate a routine or package with an instantiation of another generic package which will make the whole idea of generics much better. So you will be able to to something like this: generic with Some_Instantion_Of the generic Queue package; -- I dunno the syntax procedure Run_Proc(Item : Some_Instantiation_Of.Item) is begin SIO.Enqueue(Item); SIO.Dequeue(Item); SIO.Do_Anything_in_the_generic_package(Item); end; --Thor collard@capsrv.jhuapl.edu dlc@ddsdx2.jhuapl.edu