home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!umn.edu!The-Star.honeywell.com!saifr00.cfsat.honeywell.com!lam
- From: lam@saifr00.cfsat.honeywell.com (Josh Lam)
- Newsgroups: comp.lang.ada
- Subject: Novice Question On Generics
- Message-ID: <1992Sep15.184345.12197@saifr00.cfsat.honeywell.com>
- Date: 15 Sep 92 18:43:45 GMT
- Organization: Honeywell Air Transport Systems Division
- Lines: 57
-
- Hi there:
-
- 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
-
- ... ...
-
- type A_record is type B_record is
- record record
- ... ...
- end record end record
-
- package my_QA is new Queue(A_record); package my_QB is new Queue(B_record);
-
- ... ...
-
- Run_Proc(X : A_record); Run_Proc(Y : B_record);
-
- ... ...
-
- end A; end B;
-
-
- Now the Run_Proc procedures for both packages will look like:
-
- -- Run_Proc in package A -- Run_Proc in package B
-
- Run_Proc(X : A_record) is Run_Proc(Y : B_record) is
- begin begin
- my_QA.enqueue(X); my_QB.enqueue(Y);
- end Run_Proc; end Run_Proc;
-
-
- Basically, they contain the same functionality. In this example, I only
- wrote one line of code for simplicity of illustration, in reality, there
- could be more lines of code but same functionality. The only difference
- is the queue instantiations my_QA and my_QB.
-
- 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
- and my_QB ie they are private members to A and B respectively and Run_Proc is
- the only interface to the outside world. ie, The user only need to type
- A.Run_Proc(X) or B.Run_Proc(Y).
-
-
- Thanks in advance.
-
- --
- Josh Lam
- Honeywell Inc
- lam@saifr00.cfsat.honeywell.com
-