File: RM-8-3.html

package info (click to toggle)
ada-reference-manual 20021112web-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 18,652 kB
  • ctags: 8,921
  • sloc: makefile: 52; sh: 20
file content (258 lines) | stat: -rw-r--r-- 19,668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>Ada95 - Visibility</TITLE>
    <META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
    <META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
    <STYLE type="text/css">
    DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
    TT {font-family: "Courier New", monospace}
    DT {display: compact}
    DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
    DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
    DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
    DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
    DIV.Index {font-family: "Times New Roman", Times, serif}
    DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
    DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
    DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
    DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
    DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
    DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
    DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left:  10.0em; margin-bottom: 0.6em}
    DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
    DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
    DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
    DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
    DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left:  15.0em; margin-bottom: 0.6em}
    UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
    DD.Hanging {margin-left: 6.0em}
    DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.IndentedHanging {margin-left: 2.0em}
    DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.HangingInBulleted {margin-left: 4.0em}
    DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.SmallHanging {margin-left: 7.5em}
    DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.SmallIndentedHanging {margin-left: 2.0em}
    DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.SmallHangingInBulleted {margin-left: 5.0em}
    DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.Enumerated {margin-left: 2.0em}
    DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.SmallEnumerated {margin-left: 2.5em}
    DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    </STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="RM-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-8-2.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-8-4.html">Next</A></P>
<HR>
<H1> 8.3 Visibility</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I3188"></A>The <I>visibility rules</I>,
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. </DIV>

<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I3189"></A><A NAME="I3190"></A><A NAME="I3191"></A>A
declaration is defined to be <I>directly visible</I> at places where
a <FONT FACE="Arial, Helvetica">name</FONT> consisting of only an <FONT FACE="Arial, Helvetica">identifier</FONT>
or <FONT FACE="Arial, Helvetica">operator_symbol</FONT> is sufficient
to denote the declaration; that is, no <FONT FACE="Arial, Helvetica">selected_component</FONT>
notation or special context (such as preceding =&gt; in a named association)
is necessary to denote the declaration. <A NAME="I3192"></A>A declaration
is defined to be <I>visible</I> wherever it is directly visible, as well
as at other places where some <FONT FACE="Arial, Helvetica">name</FONT>
(such as a <FONT FACE="Arial, Helvetica">selected_component</FONT>) can
denote the declaration.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;The syntactic category <FONT FACE="Arial, Helvetica">direct_name</FONT>
is used to indicate contexts where direct visibility is required. The
syntactic category <FONT FACE="Arial, Helvetica">selector_name</FONT>
is used to indicate contexts where visibility, but not direct visibility,
is required.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I3193"></A><A NAME="I3194"></A>There
are two kinds of direct visibility: <I>immediate visibility</I> and <I>use-visibility</I>.
<A NAME="I3195"></A>A declaration is immediately visible at a place if
it is directly visible because the place is within its immediate scope.
<A NAME="I3196"></A>A declaration is use-visible if it is directly visible
because of a <FONT FACE="Arial, Helvetica">use_clause</FONT> (see <A HREF="RM-8-4.html">8.4</A>).
Both conditions can apply.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I3197"></A>A declaration can be <I>hidden</I>,
either from direct visibility, or from all visibility, within certain
parts of its scope. <A NAME="I3198"></A>Where <I>hidden from all visibility</I>,
it is not visible at all (neither using a <FONT FACE="Arial, Helvetica">direct_name</FONT>
nor a <FONT FACE="Arial, Helvetica">selector_name</FONT>). <A NAME="I3199"></A>Where
<I>hidden from direct visibility</I>, only direct visibility is lost;
visibility using a <FONT FACE="Arial, Helvetica">selector_name</FONT>
is still possible.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I3200"></A>Two or more declarations are
<I>overloaded</I> if they all have the same defining name and there is
a place where they are all directly visible. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I3201"></A>The declarations of callable
entities (including enumeration literals) are <I>overloadable</I>, meaning
that overloading is allowed for them. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I3202"></A>Two declarations are <I>homographs</I>
if they have the same defining name, and, if both are overloadable, their
profiles are type conformant. <A NAME="I3203"></A>An inner declaration
hides any outer homograph from direct visibility.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9/1</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Two homographs
are not generally allowed immediately within the same declarative region
unless one <I>overrides</I> the other (see Legality Rules below). <A NAME="I3204"></A>The
only declarations that are <A NAME="I3205"></A><I>overridable</I> 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: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10/1</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A declaration that is not overridable overrides one that
is overridable, regardless of which declaration occurs first; </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The implicit declaration of an inherited operator overrides
that of a predefined operator; </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An implicit declaration of an inherited subprogram overrides
a previous implicit declaration of an inherited subprogram.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>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.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I3206"></A><A NAME="I3207"></A>A
declaration is visible within its scope, except where hidden from all
visibility, as follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC><A NAME="I3208"></A>An overridden declaration is hidden
from all visibility within the scope of the overriding declaration. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<UL Class="Bulleted" Style="margin-bottom: 0.3em"><LI TYPE=DISC><A NAME="I3209"></A>A declaration is hidden from all visibility
until the end of the declaration, except: </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<UL Class="NestedBulleted"><LI TYPE=DISC>For a record type or record extension, the declaration
is hidden from all visibility only until the reserved word <B>record</B>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<UL Class="NestedBulleted"><LI TYPE=DISC>For a <FONT FACE="Arial, Helvetica">package_declaration</FONT>,
task declaration, protected declaration, <FONT FACE="Arial, Helvetica">generic_package_declaration</FONT>,
or <FONT FACE="Arial, Helvetica">subprogram_body</FONT>, the declaration
is hidden from all visibility only until the reserved word <B>is</B>
of the declaration. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC><A NAME="I3210"></A>If the completion of a declaration
is a declaration, then within the scope of the completion, the first
declaration is hidden from all visibility. Similarly, a <FONT FACE="Arial, Helvetica">discriminant_specification</FONT>
or <FONT FACE="Arial, Helvetica">parameter_specification</FONT> is hidden
within the scope of a corresponding <FONT FACE="Arial, Helvetica">discriminant_specification</FONT>
or <FONT FACE="Arial, Helvetica">parameter_specification</FONT> of a
corresponding completion, or of a corresponding <FONT FACE="Arial, Helvetica">accept_statement</FONT>.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC><A NAME="I3211"></A>The declaration of a library unit (including
a <FONT FACE="Arial, Helvetica">library_unit_renaming_declaration</FONT>)
is hidden from all visibility except at places that are within its declarative
region or within the scope of a <FONT FACE="Arial, Helvetica">with_clause</FONT>
that mentions it. 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 <FONT FACE="Arial, Helvetica">with_clause</FONT> that
mentions the child.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I3212"></A><A NAME="I3213"></A><A NAME="I3214"></A><A NAME="I3215"></A>A
declaration with a <FONT FACE="Arial, Helvetica">defining_identifier</FONT>
or <FONT FACE="Arial, Helvetica">defining_operator_symbol</FONT> is immediately
visible (and hence directly visible) within its immediate scope <A NAME="I3216"></A>
except where hidden from direct visibility, as follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC><A NAME="I3217"></A>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;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC><A NAME="I3218"></A>A declaration is also hidden from direct
visibility where hidden from all visibility. </LI></UL>

<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I3219"></A>A <FONT FACE="Arial, Helvetica">direct_name</FONT>
shall resolve to denote a directly visible declaration whose defining
name is the same as the <FONT FACE="Arial, Helvetica">direct_name</FONT>.
<A NAME="I3220"></A>A <FONT FACE="Arial, Helvetica">selector_name</FONT>
shall resolve to denote a visible declaration whose defining name is
the same as the <FONT FACE="Arial, Helvetica">selector_name</FONT>. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;These rules on visibility and direct visibility
do not apply in a <FONT FACE="Arial, Helvetica">context_clause</FONT>,
a <FONT FACE="Arial, Helvetica">parent_unit_name</FONT>, or a <FONT FACE="Arial, Helvetica">pragma</FONT>
that appears at the place of a <FONT FACE="Arial, Helvetica">compilation_unit</FONT>.
For those contexts, see the rules in <A HREF="RM-10-1-6.html">10.1.6</A>,
``<A HREF="RM-10-1-6.html">Environment-Level Visibility Rules</A>''.
</DIV>

<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>26/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A non-overridable 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 non-overridable 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 <FONT FACE="Arial, Helvetica">context_clause</FONT>
for a <FONT FACE="Arial, Helvetica">subunit</FONT> is illegal if it mentions
(in a <FONT FACE="Arial, Helvetica">with_clause</FONT>) some library
unit, and there is a homograph of the library unit that is visible at
the place of the corresponding stub, and the homograph and the mentioned
library unit are both declared immediately within the same declarative
region. <A NAME="I3221"></A>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. <A NAME="I3222"></A></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>5&nbsp;&nbsp;Visibility for compilation
units follows from the definition of the environment in <A HREF="RM-10-1-4.html">10.1.4</A>,
except that it is necessary to apply a <FONT FACE="Arial, Helvetica">with_clause</FONT>
to obtain visibility to a <FONT FACE="Arial, Helvetica">library_unit_declaration</FONT>
or <FONT FACE="Arial, Helvetica">library_unit_renaming_declaration</FONT>.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>6&nbsp;&nbsp;In addition to the visibility
rules given above, the meaning of the occurrence of a <FONT FACE="Arial, Helvetica">direct_name</FONT>
or <FONT FACE="Arial, Helvetica">selector_name</FONT> at a given place
in the text can depend on the overloading rules (see <A HREF="RM-8-6.html">8.6</A>).</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>7&nbsp;&nbsp;Not all contexts where
an <FONT FACE="Arial, Helvetica">identifier</FONT>, <FONT FACE="Arial, Helvetica">character_literal</FONT>,
or <FONT FACE="Arial, Helvetica">operator_symbol</FONT> are allowed require
visibility of a corresponding declaration. Contexts where visibility
is not required are identified by using one of these three syntactic
categories directly in a syntax rule, rather than using <FONT FACE="Arial, Helvetica">direct_name</FONT>
or <FONT FACE="Arial, Helvetica">selector_name</FONT>. </FONT></DIV>

<HR>
<P><A HREF="RM-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-8-2.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-8-4.html">Next</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-TTL.html">Legal</A></P>
</BODY>
</HTML>