Contents Index 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
{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 a
library_item,
and within a
with_clause, the only
declarations that are visible are those that are
library_items
of the environment, and the only declarations that are directly visible
are those that are root
library_items
of the environment.
{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
Reason: 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.d
Reason: 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.
Wording Changes from Ada 83
5.a
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.
5.b
Note that a context_clause
is not part of any declarative region.
5.c
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.
Contents Index Search Previous Next Legal