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,40d697764033dbdb X-Google-Attributes: gid103376,public From: "Norman H. Cohen" Subject: Re: types in procedure arguments Date: 1996/09/30 Message-ID: <3250227D.4B43@watson.ibm.com>#1/1 X-Deja-AN: 186291775 references: <52nj8q$4ck@noc2.drexel.edu> to: Chris Papademetrious content-type: text/plain; charset=us-ascii organization: IBM Thomas J. Watson Research Center mime-version: 1.0 reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; I) Date: 1996-09-30T00:00:00+00:00 List-Id: Chris Papademetrious wrote: > I want to pass the type LIST_ID to a procedure I've defined. The > problem is that I've defined the type LIST_ID twice: > > 1. at the beginning of the level where I call this procedure > 2. in the package that holds the procedure itself, so I can use the > type LIST_ID as a procedure argument > > The problem here is that each of these originates a new and unique > "type LIST_ID" which aren't compatible with each other. Thus, the > calling statement that passes a type (1) of LIST_ID does not match the > type (2) LIST_ID of the argument in the procedure being called! > > This seems basic, the idea of calling a subprogram with a type, and > needing to define the type in a package so the subprogram can be > declared. How is this handled in Ada 95??? I'd be more than happy to > provide a small test program, if anyone could lend me a hand. I've > been battling this for two weeks, and no books have been of any help. The terminology you are using ("the level where I call this procedure", "use the type LIST_ID as a procedure argument", "calling statement that passes a type", "calling a subprogram with a type") does not make any sense in Ada terms, so I can only guess what you mean. You can pass a type to a generic template to create an instance of that template; you can pass a parameter OF a given type to a procedure. Even though your original query mentioned generic units, my best guess is that what you are concerned with is passing a an object OF a given type to a subprogram. If you want one compilation unit to declare a subprogram, another to call the subprogram, and a third to declare the type used for one of the parameters, the first two compilation units can be given a with clause naming the third one. For example: package Parameter_Types is type Parameter_Type is ...; end Parameter_Types; with Parameter_Types; use Parameter_Types; procedure Callee (Formal_Parameter: in Parameter_Type) is ... begin ... end Callee; with Parameter_Types, Callee; use Parameter_Types; procedure Caller is Actual_Parameter: Parameter_Type; ... begin Callee (Actual_Parameter); ... end Caller; The first of these three units could just as easily have been the instantiation of a generic package: with Generic_Template; package Parameter_Types is new Generic_Template ( ... ); Does this answer your question? -- Norman H. Cohen mailto:ncohen@watson.ibm.com http://www.research.ibm.com/people/n/ncohen