comp.lang.ada
 help / color / mirror / Atom feed
From: NCOHEN@IBM.COM ("Norman H. Cohen")
Subject: Visibility in Embedded Packages
Date: 30 Oct 90 14:44:24 GMT	[thread overview]
Message-ID: <9010301603.AA12259@ajpo.sei.cmu.edu> (raw)

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

             reply	other threads:[~1990-10-30 14:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-10-30 14:44 "Norman H. Cohen" [this message]
  -- strict thread matches above, loose matches on Subject: below --
1990-10-28 15:51 Visibility in Embedded Packages Richard Dye
1990-10-29 15:29 ` stt
1990-10-31 20:21 ` Jean Pierre Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox