8.3 Visibility
The 
visibility rules, 
given below, determine which declarations are visible and directly visible 
at each place within a program. The visibility rules apply to both explicit 
and implicit declarations. 
Static Semantics
A 
declaration is defined to be 
directly visible at places where 
a 
name consisting 
of only an 
identifier 
or 
operator_symbol 
is sufficient to denote the declaration; that is, no 
selected_component 
notation or special context (such as preceding => in a named association) 
is necessary to denote the declaration. 
A declaration 
is defined to be 
visible wherever it is directly visible, as well 
as at other places where some 
name 
(such as a 
selected_component) 
can denote the declaration.
The syntactic category 
direct_name 
is used to indicate contexts where direct visibility is required. The 
syntactic category 
selector_name 
is used to indicate contexts where visibility, but not direct visibility, 
is required.
There are 
two kinds of direct visibility: 
immediate visibility and 
use-visibility. 
A declaration is immediately visible at a place if 
it is directly visible because the place is within its immediate scope. 
A declaration is use-visible if it is directly visible 
because of a 
use_clause 
(see 
8.4). Both conditions can apply.
A declaration can be 
hidden, 
either from direct visibility, or from all visibility, within certain 
parts of its scope. 
Where 
hidden from all visibility, 
it is not visible at all (neither using a 
direct_name 
nor a 
selector_name). 
Where 
hidden from direct visibility, only 
direct visibility is lost; visibility using a 
selector_name 
is still possible.
Two or more declarations are 
overloaded if they all have the same defining name and there is 
a place where they are all directly visible. 
The declarations of callable 
entities (including enumeration literals) are 
overloadable, meaning 
that overloading is allowed for them. 
Two declarations are 
homographs 
if they have the same defining name, and, if both are overloadable, their 
profiles are type conformant. 
An inner declaration 
hides any outer homograph from direct visibility.
Two homographs are 
not generally allowed immediately within the same declarative region 
unless one 
overrides the other (see Legality Rules below). 
The 
only declarations that are 
overridable are 
the implicit declarations for predefined operators and inherited primitive 
subprograms. A declaration overrides another homograph that occurs immediately 
within the same declarative region in the following cases: 
A declaration that is not overridable overrides 
one that is overridable, regardless of which declaration occurs first; 
The implicit declaration of an inherited operator 
overrides that of a predefined operator; 
An implicit declaration of an inherited subprogram 
overrides a previous implicit declaration of an inherited subprogram.
If two or more homographs 
are implicitly declared at the same place:
If at least one is a subprogram 
that is neither a null procedure nor an abstract subprogram, and does 
not require overriding (see 
3.9.3), then 
they override those that are null procedures, abstract subprograms, or 
require overriding. If more than one such homograph remains that is not 
thus overridden, then they are all hidden from all visibility.
Otherwise (all are null procedures, 
abstract subprograms, or require overriding), then any null procedure 
overrides all abstract subprograms and all subprograms that require overriding; 
if more than one such homograph remains that is not thus overridden, 
then if they are all fully conformant with one another, one is chosen 
arbitrarily; if not, they are all hidden from all visibility. 
For an implicit declaration of a primitive subprogram 
in a generic unit, there is a copy of this declaration in an instance. 
However, a whole new set of primitive subprograms is implicitly declared 
for each type declared within the visible part of the instance. These 
new declarations occur immediately after the type declaration, and override 
the copied ones. The copied ones can be called only from within the instance; 
the new ones can be called only from outside the instance, although for 
tagged types, the body of a new one can be executed by a call to an old 
one. 
A 
declaration is visible within its scope, except where hidden from all 
visibility, as follows: 
An overridden declaration is 
hidden from all visibility within the scope of the overriding declaration. 
A 
declaration is hidden from all visibility until the end of the declaration, 
except: 
For a record type or record extension, 
the declaration is hidden from all visibility only until the reserved 
word record;
For a task declaration or protected 
declaration, the declaration is hidden from all visibility only until 
the reserved word with of the declaration if there is one, or 
the reserved word is of the declaration if there is no with.
The declaration of a library 
unit (including a 
library_unit_renaming_declaration) 
is hidden from all visibility at places outside its declarative region 
that are not within the scope of a 
nonlimited_with_clause 
that mentions it. The limited view of a library package is hidden from 
all visibility at places that are not within the scope of a 
limited_with_clause 
that mentions it; in addition, the limited view is hidden from all visibility 
within the declarative region of the package, as well as within the scope 
of any 
nonlimited_with_clause 
that mentions the package. Where the declaration of the limited view 
of a package is visible, any name that denotes the package denotes the 
limited view, including those provided by a package renaming.
For each declaration or renaming of a generic unit 
as a child of some parent generic package, there is a corresponding declaration 
nested immediately within each instance of the parent. Such a nested 
declaration is hidden from all visibility except at places that are within 
the scope of a 
with_clause 
that mentions the child.
A declaration is hidden from 
direct visibility within the immediate scope of a homograph of the declaration, 
if the homograph occurs within an inner declarative region;
A declaration is also hidden 
from direct visibility where hidden from all visibility. 
Name Resolution Rules
Legality Rules
 A nonoverridable declaration is illegal if there 
is a homograph occurring immediately within the same declarative region 
that is visible at the place of the declaration, and is not hidden from 
all visibility by the nonoverridable declaration. In addition, a type 
extension is illegal if somewhere within its immediate scope it has two 
visible components with the same name. Similarly, the 
context_clause 
for a compilation unit is illegal if it mentions (in a 
with_clause) 
some library unit, and there is a homograph of the library unit that 
is visible at the place of the compilation unit, and the homograph and 
the mentioned library unit are both declared immediately within the same 
declarative region.
 These rules also apply to dispatching 
operations declared in the visible part of an instance of a generic unit. 
However, they do not apply to other overloadable declarations in an instance; 
such declarations may have type conformant profiles in the instance, 
so long as the corresponding declarations in the generic were not type 
conformant. 
6  In addition to the visibility rules given 
above, the meaning of the occurrence of a 
direct_name 
or 
selector_name 
at a given place in the text can depend on the overloading rules (see 
8.6).
 Ada 2005 and 2012 Editions sponsored in part by Ada-Europe
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe