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: 29 Jun 93 21:06:26 GMT From: rational.com!geneo@uunet.uu.net (Gene Ouye) Subject: Re: Elaboration and parameters Message-ID: <1993Jun29.210626.22463@rational.com> List-Id: Risto Kaivola (rkaivola@mits.mdata.fi) wrote: : Consider the following Ada program: : -------------- : -- : -- The purpose of this program is test exactly when PROGRAM_ERROR is : -- raised if the body of a subprogram has not yet been elaborated. : -- : with TEXT_IO; use TEXT_IO; : procedure PROC is : MY_EXCEPTION : exception; : subtype S is INTEGER range 0 .. 1; : A : S; : function EXCEPT(ARG : S) return S is : begin : raise MY_EXCEPTION; : return S(0); : end EXCEPT; : procedure CURIOUS(ARG : S) is separate; : begin : CURIOUS(EXCEPT(A)); : exception : when MY_EXCEPTION => : PUT("E"); : when PROGRAM_ERROR => : PUT("NE"); : end PROC; : ------------ : So, are the parameters of a subprogram evaluated if a body has : not been provided? In my opinion, the Ada83 LRM is not exactly : clear on this. Are you asking what will happen if you try to execute the above code without the corresponding subunit for the procedure CURIOUS? If so, you should not get Program_Error because the program should not be linked without the subunit. To do so would violate LRM 10.2(4). If you want to raise Program_Error, try the following: procedure I_Wont_Elaborate; -- this spec will elaborate, but the body won't package A_Package is procedure Some_Procedure_That_Wont_Get_Called; end A_Package; with A_Package; procedure I_Wont_Elaborate is begin A_Package.Some_Procedure_That_Wont_Get_Called; end I_Wont_Elaborate; with I_Wont_Elaborate; package body A_Package is procedure Some_Procedure_That_Wont_Get_Called is begin null; -- it doesn't matter here, we won't get called end Some_Procedure_That_Wont_Get_Called; begin I_Wont_Elaborate; -- an appropriate call... end A_Package; I make no claims as to the invalidity of this code, I just typed it in off the top of my head. I'm sure others can come up with more succinct examples (but that's not an invitation for a new thread!-) Have fun with this, Gene Ouye (geneo@rational.com) (301) 897-4014