Annotated Ada Reference ManualLegal Information
Table of Contents   Index   References   Search   Previous   Next 

 10.1.6 Environment-Level Visibility Rules

1
[The normal visibility rules do not apply within a parent_unit_name or a context_clause, nor within a pragma that appears at the place of a compilation unit. The special visibility rules for those contexts are given here.] 

Static Semantics

2/2
{AI95-00217-06} {AI95-00312-01} {directly visible (within the parent_unit_name of a library unit) [partial]} {visible (within the parent_unit_name of a library unit) [partial]} {directly visible (within a with_clause) [partial]} {visible (within a with_clause) [partial]} Within the parent_unit_name at the beginning of an explicit a library_item, and within a nonlimited_with_clause with_clause, the only declarations that are visible are those that are explicit library_items of the environment, and the only declarations that are directly visible are those that are explicit root library_items of the environment. Within a limited_with_clause, the only declarations that are visible are those that are the implicit declaration of the limited view of a library package of the environment, and the only declarations that are directly visible are those that are the implicit declaration of the limited view of a root library package. {notwithstanding} Notwithstanding the rules of 4.1.3, an expanded name in a with_clause may consist of a prefix that denotes a generic package and a selector_name that denotes a child of that generic package. [(The child is necessarily a generic unit; see 10.1.1.)]
2.a
Ramification: In “package P.Q.R is ... end P.Q.R;”, this rule requires P to be a root library unit, and Q to be a library unit (because those are the things that are directly visible and visible). Note that visibility does not apply between the “end” and the “;”.
2.b
Physically nested declarations are not visible at these places.
2.c
Although Standard is visible at these places, it is impossible to name it, since it is not directly visible, and it has no parent.
2.c.1/2
{AI95-00217-06} Only compilation units defining limited views can be mentioned in a limited_with_clause, while only compilation units defining full views (that is, the explicit declarations) can be mentioned in a nonlimited_with_clause. This resolves the conflict inherent in having two compilation units with the same defining name. 
2.d/2
This paragraph was deleted.Reason: {AI95-00312-01} The “notwithstanding” part allows “with A.B;” where A is a generic library package and B is one of its (generic) children. This is necessary because it is not normally legal to use an expanded name to reach inside a generic package. 
3
{directly visible (within a use_clause in a context_clause) [partial]} {visible (within a use_clause in a context_clause) [partial]} {directly visible (within a pragma in a context_clause) [partial]} {visible (within a pragma in a context_clause) [partial]} Within a use_clause or pragma that is within a context_clause, each library_item mentioned in a previous with_clause of the same context_clause is visible, and each root library_item so mentioned is directly visible. In addition, within such a use_clause, if a given declaration is visible or directly visible, each declaration that occurs immediately within the given declaration's visible part is also visible. No other declarations are visible or directly visible.
3.a
Discussion: Note the word “same”. For example, if a with_clause on a declaration mentions X, this does not make X visible in use_clauses and pragmas that are on the body. The reason for this rule is the one-pass context_clauses Language Design Principle.
3.b
Note that the second part of the rule does not mention pragmas. 
4
{directly visible (within the parent_unit_name of a subunit) [partial]} {visible (within the parent_unit_name of a subunit) [partial]} Within the parent_unit_name of a subunit, library_items are visible as they are in the parent_unit_name of a library_item; in addition, the declaration corresponding to each body_stub in the environment is also visible. 
4.a
Ramification: For a subprogram without a separate subprogram_declaration, the body_stub itself is the declaration. 
5
{directly visible (within a pragma that appears at the place of a compilation unit) [partial]} {visible (within a pragma that appears at the place of a compilation unit) [partial]} Within a pragma that appears at the place of a compilation unit, the immediately preceding library_item and each of its ancestors is visible. The ancestor root library_item is directly visible.
6/2
{AI95-00312-01} {notwithstanding} Notwithstanding the rules of 4.1.3, an expanded name in a with_clause, a pragma in a context_clause, or a pragma that appears at the place of a compilation unit may consist of a prefix that denotes a generic package and a selector_name that denotes a child of that generic package. [(The child is necessarily a generic unit; see 10.1.1.)] 
6.a/2
Reason: This rule allows with A.B; and pragma Elaborate(A.B); where A is a generic library package and B is one of its (generic) children. This is necessary because it is not normally legal to use an expanded name to reach inside a generic package. 

Wording Changes from Ada 83

6.b
The special visibility rules that apply within a parent_unit_name or a context_clause, and within a pragma that appears at the place of a compilation_unit are clarified.
6.c
Note that a context_clause is not part of any declarative region.
6.d
We considered making the visibility rules within parent_unit_names and context_clauses follow from the context of compilation. However, this attempt failed for various reasons. For example, it would require use_clauses in context_clauses to be within the declarative region of Standard, which sounds suspiciously like a kludge. And we would still need a special rule to prevent seeing things (in our own context_clause) that were with-ed by our parent, etc. 

Wording Changes from Ada 95

6.e/2
{AI95-00217-06} Added separate visibility rules for limited_with_clauses; the existing rules apply only to nonlimited_with_clauses.
6.f/2
{AI95-00312-01} Clarified that the name of a generic child unit may appear in a pragma in a context_clause.






Table of Contents   Index   References   Search   Previous   Next 
Ada-Europe Sponsored by Ada-Europe