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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!usc!ucsd!ucbvax!IBM.COM!NCOHEN From: NCOHEN@IBM.COM ("Norman H. Cohen") Newsgroups: comp.lang.ada Subject: Visibility in Embedded Packages Message-ID: <9010301603.AA12259@ajpo.sei.cmu.edu> Date: 30 Oct 90 14:44:24 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: Dick Dye writes: >The code we tried is: > >package Standard_Types is >Min_Integer : constant := -1 * (2 ** 31); >Max_Integer : constant := (2 ** 31) -1; >type Integer_Type is range Min_Integer .. Max_Integer; > >package Operators is >function "+"(L,R : Integer_Type) return Integer_Type renames "+"; >end Operators; > >end Standard_Types; > >The above works fine on the Telesoft 1.4. > >The Telesoft 1.3 requires: >function "+"(L,R : Integer_Type) return Integer_Type renames Standard."+"; > >The VAX requires: >function "+"(L,R : Integer_Type) return Integer_Type renames Standard_Types."+"; The version said to be required by Telesoft 1.3 can be dismissed out of hand: There is no version of "+" for the user-declared type Integer_Type in package Standard. The version shown in full, said to be accepted by Telesoft 1.4, is also incorrect. The inner declaration of "+" (the renaming declaration) is a homograph of the outer declaration of "+" (the subprogram declaration), since they have the same name and parameter/result-type profile. Therefore the outer declaration is hidden within the immediate scope of the inner declaration (see RM 8.3(15)). The immediate scope of the inner declaration starts at the BEGINNING of that declaration (RM 8.2(2)), so the outer declaration is hidden within the renaming declaration itself. (On the other hand, even though the SCOPE of the inner declaration starts at the beginning of that declaration, the inner declaration does not become VISIBLE until the end of that declaration--see RM 8.3(5)--so neither the "+" that hides nor the "+" that is hidden is visible within the renaming declaration.) However, the outer declaration can be made visible by selection anywhere in its scope after the declaration itself, so the version said to be accepted on the VAX is legal. (The outer declaration of "+" is visible by selection in the context Standard_Types."+" both by RM 8.3(7)-- because "+" is exported by Standard_Types--and by RM 8.3(13)--because Standard_Types is the name of a surrounding construct.) It is irrelevant that the two declarations of "+" declare names denoting the same entity. The visibility rules are given in terms of declarations, not entities. Two declarations corresponding to the same entity can be homographs. Norman H. Cohen