8.4 Use Clauses
1
A
use_package_clause
achieves direct visibility of declarations that appear in the visible
part of a package; a
use_type_clause
achieves direct visibility of the primitive operators of a type.
Syntax
2
3
use_package_clause ::= use package_name {,
package_name};
4
Legality Rules
5/2
Static Semantics
6
7
For a
use_clause
immediately within a declarative region, the scope is the portion of
the declarative region starting just after the
use_clause
and extending to the end of the declarative region. However, the scope
of a
use_clause
in the private part of a library unit does not include the visible part
of any public descendant of that library unit.
7.1/2
8/2
For each package named in a
use_package_clause
whose scope encloses a place, each declaration that occurs immediately
within the declarative region of the package is
potentially use-visible
at this place if the declaration is visible at this place. For each type
T or
T'Class named in a
use_type_clause
whose scope encloses a place, the declaration of each primitive operator
of type
T is potentially use-visible at this place if its declaration
is visible at this place.
9
A
declaration is
use-visible if it is potentially use-visible, except
in these naming-conflict cases:
10
- A potentially use-visible declaration
is not use-visible if the place considered is within the immediate scope
of a homograph of the declaration.
11
- Potentially use-visible declarations
that have the same identifier
are not use-visible unless each of them is an overloadable declaration.
Dynamic Semantics
12
Examples
13
Example of a use
clause in a context clause:
14
with Ada.Calendar; use Ada;
15
Example of a use type
clause:
16
use type Rational_Numbers.Rational; --
see 7.1
Two_Thirds: Rational_Numbers.Rational := 2/3;