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: 2 Oct 92 23:25:01 GMT From: dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!nigel.msen.com!caen!de ccrl!news.crl.dec.com!pa.dec.com!engage.pko.dec.com!nntpd.lkg.dec.com!nntpd2.cx o.dec.com!bonmot!wallace@ (Richard Wallace) Subject: Generic Package Visibility Problems! (help) Message-ID: <1992Oct2.232501.1859@nntpd2.cxo.dec.com> List-Id: young@gdfwc3 (Mark Young) writes: : I am having visibility problems with generic packages. : Here's an example: : file #1 : ----------------------------------------------- : generic : Generic_Parameter : Generic_Parameter_Type; : package Color is : type RGB_Type is (RED,GREEN,BLUE); : function Get_Color return RGB_Type; : end Color; : ---------------------------------------------- : file #2 : ---------------------------------------------- : with Color; : package Caller is : package C_1 is new Caller( Generic_Argument ); : procedure Test_Color; : end Caller; : package body Caller is : procedure Test_Color is separate; : end Caller; : --------------------------------------------- : file #3 : --------------------------------------------- : separate( Caller ) : procedure Test_Color is : begin : if ( C_1.Get_Color = C_1.RED ) then : ------- : null; : end if; : end Test_Color; : ---------------------------------------------- : This will not work. For some reason the compiler cannot : resolve C_1.RED. It tells me that = is not a legal : operation, that C_1.Get_Color returns type RGB_Type but, : that it does not understand C_1.RED and that perhaps I : needed a "use" clause in the body of Caller. I don't : understand this. My understanding of Ada scoping would : lead me to believe that this is correct. Am I missing : something? : : BTW: this is not a complete example, it is only to illustrate : a point. : : Thanks, : : Mark Young Well Mark, This won't work for the following reasons: 1) You haven't used the generic formal in your generic package. 2) You have passed to the generic formal a very odd data type. 3) You are using a function in the body of TEST_COLOR wrong. The following corrected program does what you want to do. -- ++ -- file #1 -- -- generic type GENERIC_PARAMETER_TYPE is (<>); package COLOR is RGB_TYPE : GENERIC_PARAMETER_TYPE; function GET_COLOR return GENERIC_PARAMETER_TYPE; end COLOR; -- ++ -- file #2 -- -- with COLOR; package CALLER is type ZIPPY is ( RED, GREEN, BLUE ); package C_1 is new COLOR( ZIPPY ); procedure Test_Color; end CALLER; package body CALLER is procedure TEST_COLOR is separate; end CALLER; --------------------------------------------- --file #3 --------------------------------------------- separate( CALLER ) procedure TEST_COLOR is begin if ( RED = C_1.GET_COLOR ) THEN null; end if; end TEST_COLOR; ============================ Hope this helps! Richard Wallace Digital Equipment Corporation 301 Rockrimmon Blvd. South CXO2-1/7A Colorado Springs, CO 80919-2398 (719)548-2792 "The opinions expressed are my own, Uncle Ken or Uncle Bob may, or may not, agree with me."