File: AA-7-3-1.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 (376 lines) | stat: -rw-r--r-- 28,288 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>AARM95 - Private Operations</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="AA-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-7-3.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-7-4.html">Next</A></P>
<HR>
<H1> 7.3.1 Private Operations</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;[For a type declared in the visible part of a
package or generic package, certain operations on the type do not become
visible until later in the package -- either in the private part or the
body. <A NAME="I3240"></A>Such <I>private operations</I> are available
only inside the declarative region of the package or generic package.]
</DIV>

<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;The predefined operators that exist for a given
type are determined by the classes to which the type belongs. For example,
an integer type has a predefined &quot;+&quot; operator. In most cases,
the predefined operators of a type are declared immediately after the
definition of the type; the exceptions are explained below. Inherited
subprograms are also implicitly declared immediately after the definition
of the type, except as stated below.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0019">8652/0019</A></I>}
For a composite type, the characteristics (see <A HREF="AA-7-3.html">7.3</A>)
of the type are determined in part by the characteristics of its component
types. At the place where the composite type is declared, the only characteristics
of component types used are those characteristics visible at that place.
If later <U>immediately within the declarative region in which the composite
type is declared</U><S>within the immediate scope of the composite type</S>
additional characteristics become visible for a component type, then
any corresponding characteristics become visible for the composite type.
Any additional predefined operators are implicitly declared at that place.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0019">8652/0019</A></I>}
The corresponding rule applies to a type defined by a <FONT FACE="Arial, Helvetica">derived_type_definition</FONT>,
if there is a place <U>immediately within the declarative region in which
the type is declared</U><S>within its immediate scope</S> where additional
characteristics of its parent type become visible.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0019">8652/0019</A></I>}
<A NAME="I3241"></A><A NAME="I3242"></A><A NAME="I3243"></A>[For example,
an array type whose component type is limited private becomes nonlimited
if the full view of the component type is nonlimited and visible at some
later place <U>immediately within the declarative region in which the
array type is declared.</U><S>within the immediate scope of the array
type.</S> In such a case, the predefined &quot;=&quot; operator is implicitly
declared at that place, and assignment is allowed after that place.]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0019">8652/0019</A></I>}
Inherited primitive subprograms follow a different rule. For a <FONT FACE="Arial, Helvetica">derived_type_definition</FONT>,
each inherited primitive subprogram is implicitly declared at the earliest
place, if any, <U>immediately within the declarative region in which</U><S>within
the immediate scope of</S> the <FONT FACE="Arial, Helvetica">type_declaration</FONT><U>
occurs</U>, but after the <FONT FACE="Arial, Helvetica">type_declaration</FONT>,
where the corresponding declaration from the parent is visible. If there
is no such place, then the inherited subprogram is not declared at all.
[An inherited subprogram that is not declared at all cannot be named
in a call and cannot be overridden, but for a tagged type, it is possible
to dispatch to it.]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;For a <FONT FACE="Arial, Helvetica">private_extension_declaration</FONT>,
each inherited subprogram is declared immediately after the <FONT FACE="Arial, Helvetica">private_extension_declaration</FONT>
if the corresponding declaration from the ancestor is visible at that
place. Otherwise, the inherited subprogram is not declared for the private
extension, [though it might be for the full type]. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.a/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>There is no need
for the ``earliest place <U>immediately within the declarative region</U><S>within
the immediate scope</S>'' business here, because a <FONT FACE="Arial, Helvetica">private_extension_declaration</FONT>
will be completed with a <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>,
so we can hang the necessary private implicit declarations on the <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>The above rules
matter only when the component type (or parent type) is declared in the
visible part of a package, and the composite type (or derived type) is
declared within the declarative region of that package (possibly in a
nested package or a child package).</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.c</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1>Consider:
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.d</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B>&nbsp;Parent&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Root&nbsp;<B>is</B>&nbsp;<B>tagged</B>&nbsp;<B>null</B>&nbsp;<B>record</B>;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Op1(X&nbsp;:&nbsp;Root);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.e</FONT></DIV>
<DIV Class="SmallExamples"><TT>&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;My_Int&nbsp;<B>is</B>&nbsp;<B>range</B>&nbsp;1..10;<BR>
<B>private</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Op2(X&nbsp;:&nbsp;Root);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.f</FONT></DIV>
<DIV Class="SmallExamples"><TT>&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Another_Int&nbsp;<B>is</B>&nbsp;<B>new</B>&nbsp;My_Int;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Int_Op(X&nbsp;:&nbsp;My_Int);<BR>
<B>end</B>&nbsp;Parent;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.g</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>with</B>&nbsp;Parent;&nbsp;<B>use</B>&nbsp;Parent;<BR>
<B>package</B>&nbsp;Unrelated&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;T2&nbsp;<B>is</B>&nbsp;<B>new</B>&nbsp;Root&nbsp;<B>with</B>&nbsp;<B>null</B>&nbsp;<B>record</B>;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Op2(X&nbsp;:&nbsp;T2);<BR>
<B>end</B>&nbsp;Unrelated;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.h</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B>&nbsp;Parent.Child&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;T3&nbsp;<B>is</B>&nbsp;<B>new</B>&nbsp;Root&nbsp;<B>with</B>&nbsp;<B>null</B>&nbsp;<B>record</B>;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;Op1(T3)&nbsp;implicitly&nbsp;declared&nbsp;here.</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.i</FONT></DIV>
<DIV Class="SmallExamples"><TT>&nbsp;&nbsp;&nbsp;&nbsp;<B>package</B>&nbsp;Nested&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;T4&nbsp;<B>is</B>&nbsp;<B>new</B>&nbsp;Root&nbsp;<B>with</B>&nbsp;<B>null</B>&nbsp;<B>record</B>;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>private</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;Nested;<BR>
<B>private</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;Op2(T3)&nbsp;implicitly&nbsp;declared&nbsp;here.</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;...<BR>
<B>end</B>&nbsp;Parent.Child;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.j</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>with</B>&nbsp;Unrelated;&nbsp;<B>use</B>&nbsp;Unrelated;<BR>
<B>package</B>&nbsp;<B>body</B>&nbsp;Parent.Child&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>package</B>&nbsp;<B>body</B>&nbsp;Nested&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;Op2(T4)&nbsp;implicitly&nbsp;declared&nbsp;here.</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;Nested;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.k</FONT></DIV>
<DIV Class="SmallExamples"><TT>&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;T5&nbsp;<B>is</B>&nbsp;<B>new</B>&nbsp;T2&nbsp;<B>with</B>&nbsp;<B>null</B>&nbsp;<B>record</B>;<BR>
<B>end</B>&nbsp;Parent.Child;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.l</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Another_Int does not inherit Int_Op,
because Int_Op does not ``exist'' at the place where Another_Int is declared.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.m/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Type T2 inherits Op1 and Op2 from
Root. However, the inherited Op2 is never declared, because Parent.Op2
is never visible <U>immediately within the declarative region</U><S>within
the immediate scope</S> of T2. T2 explicitly declares its own Op2, but
this is unrelated to the inherited one -- it does not override the inherited
one, and occupies a different slot in the type descriptor.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.n</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>T3 inherits both Op1 and Op2.
Op1 is implicitly declared immediately after the type declaration, whereas
Op2 is declared at the beginning of the private part. Note that if Child
were a private child of Parent, then Op1 and Op2 would both be implicitly
declared immediately after the type declaration.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.o/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>T4 is similar to T3, except that
the earliest place <U>immediately within the declarative region containing
T4</U><S>within T4's immediate scope</S> where Root's Op2 is visible
is in the body of Nested.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.p</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>If T3 or T4 were to declare a
type-conformant Op2, this would override the one inherited from Root.
This is different from the situation with T2.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.q</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>T5 inherits Op1 and two Op2's
from T2. Op1 is implicitly declared immediately after the declaration
of T5, as is the Op2 that came from Unrelated.Op2. However, the Op2 that
originally came from Parent.Op2 is never implicitly declared for T5,
since T2's version of that Op2 is never visible (anywhere -- it never
got declared either).</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.r</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>For all of these rules, implicit
private parts and bodies are assumed as needed.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.s</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1>It
is possible for characteristics of a type to be revealed in more than
one place:</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.t</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B>&nbsp;P&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Comp1&nbsp;<B>is</B>&nbsp;<B>private</B>;<BR>
<B>private</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Comp1&nbsp;<B>is</B>&nbsp;<B>new</B>&nbsp;Boolean;<BR>
<B>end</B>&nbsp;P;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.u</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B>&nbsp;P.Q&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>package</B>&nbsp;R&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Comp2&nbsp;<B>is</B>&nbsp;<B>limited</B>&nbsp;<B>private</B>;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;A&nbsp;<B>is</B>&nbsp;<B>array</B>(Integer&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;<B>of</B>&nbsp;Comp2;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>private</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Comp2&nbsp;<B>is</B>&nbsp;<B>new</B>&nbsp;Comp1;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;A&nbsp;becomes&nbsp;nonlimited&nbsp;here.</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;&quot;=&quot;(A,&nbsp;A)&nbsp;return&nbsp;Boolean&nbsp;is&nbsp;implicitly&nbsp;declared&nbsp;here.</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;R;<BR>
<B>private</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;Now&nbsp;we&nbsp;find&nbsp;out&nbsp;what&nbsp;Comp1&nbsp;really&nbsp;is,&nbsp;which&nbsp;reveals</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;more&nbsp;information&nbsp;about&nbsp;Comp2,&nbsp;but&nbsp;we're&nbsp;not&nbsp;within</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;the&nbsp;immediate&nbsp;scope&nbsp;of&nbsp;Comp2,&nbsp;so&nbsp;we&nbsp;don't&nbsp;do&nbsp;anything</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;about&nbsp;it&nbsp;yet.</I><BR>
<B>end</B>&nbsp;P.Q;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.v</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B>&nbsp;<B>body</B>&nbsp;P.Q&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>package</B>&nbsp;<B>body</B>&nbsp;R&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;Things&nbsp;like&nbsp;&quot;<B>xor</B>&quot;(A,A)&nbsp;return&nbsp;A&nbsp;are&nbsp;implicitly</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;declared&nbsp;here.</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;R;<BR>
<B>end</B>&nbsp;P.Q;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.v.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>{<I><A HREF="defect1.html#8652/0019">8652/0019</A></I>}
<U>We say <I>immediately</I> within the declarative region in order that
types do not gain operations within a nested scope. Consider:</U> </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.v.2/1</FONT></DIV>
<DIV Class="SmallExamples"><TT><U><B>package</B>&nbsp;Outer&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>package</B>&nbsp;Inner&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Inner_Type&nbsp;<B>is</B>&nbsp;<B>private</B>;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>private</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Inner_Type&nbsp;<B>is</B>&nbsp;<B>new</B>&nbsp;Boolean;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;Inner;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Outer_Type&nbsp;<B>is</B>&nbsp;<B>array</B>(Natural&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;<B>of</B>&nbsp;Inner.Inner_Type;<BR>
<B>end</B>&nbsp;Outer;</U></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.v.3/1</FONT></DIV>
<DIV Class="SmallExamples"><TT><U><B>package</B>&nbsp;<B>body</B>&nbsp;Outer&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>package</B>&nbsp;<B>body</B>&nbsp;Inner&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;At&nbsp;this&nbsp;point,&nbsp;we&nbsp;can&nbsp;see&nbsp;that&nbsp;Inner_Type&nbsp;is&nbsp;a&nbsp;Boolean&nbsp;type.<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;But&nbsp;we&nbsp;don't&nbsp;want&nbsp;Outer_Type&nbsp;to&nbsp;gain&nbsp;an&nbsp;&quot;and&quot;&nbsp;operator&nbsp;here.<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;Inner;<BR>
<B>end</B>&nbsp;Outer;</U></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;[The Class attribute
is defined for tagged subtypes in <A HREF="AA-3-9.html">3.9</A>. In addition,]
for every subtype S of an untagged private type whose full view is tagged,
the following attribute is defined: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DL Class="Hanging"><DT>&nbsp;&nbsp;&nbsp;S'Class<DD Class="Hanging">
<A NAME="I3244"></A><A NAME="I3245"></A>Denotes the class-wide subtype
corresponding to the full view of S. This attribute is allowed only from
the beginning of the private part in which the full view is declared,
until the declaration of the full view. [After the full view, the Class
attribute of the full view can be used.] </DL>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>8&nbsp;&nbsp;Because a partial view
and a full view are two different views of one and the same type, outside
of the defining package the characteristics of the type are those defined
by the visible part. Within these outside program units the type is just
a private type or private extension, and any language rule that applies
only to another class of types does not apply. The fact that the full
declaration might implement a private type with a type of a particular
class (for example, as an array type) is relevant only within the declarative
region of the package itself including any child units.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>The consequences of this actual implementation
are, however, valid everywhere. For example: any default initialization
of components takes place; the attribute Size provides the size of the
full view; finalization is still done for controlled components of the
full view; task dependence rules still apply to components that are task
objects.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>9&nbsp;&nbsp;Partial views provide assignment
(unless the view is limited), membership tests, selected components for
the selection of discriminants and inherited components, qualification,
and explicit conversion.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>10&nbsp;&nbsp;For a subtype S of a partial
view, S'Size is defined (see <A HREF="AA-13-3.html">13.3</A>). For an
object A of a partial view, the attributes A'Size and A'Address are defined
(see <A HREF="AA-13-3.html">13.3</A>). The Position, First_Bit, and Last_Bit
attributes are also defined for discriminants and inherited components.
</FONT></DIV>

<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<I>Example of a
type with private operations:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT><B>package</B>&nbsp;Key_Manager&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Key&nbsp;<B>is</B>&nbsp;<B>private</B>;<BR>
&nbsp;&nbsp;&nbsp;Null_Key&nbsp;:&nbsp;<B>constant</B>&nbsp;Key;&nbsp;--<I>&nbsp;a&nbsp;deferred&nbsp;constant&nbsp;declaration&nbsp;(see&nbsp;<A HREF="AA-7-4.html">7.4</A>)</I><BR>
&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Get_Key(K&nbsp;:&nbsp;<B>out</B>&nbsp;Key);<BR>
&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;&quot;&lt;&quot;&nbsp;(X,&nbsp;Y&nbsp;:&nbsp;Key)&nbsp;<B>return</B>&nbsp;Boolean;<BR>
<B>private</B><BR>
&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Key&nbsp;<B>is</B>&nbsp;<B>new</B>&nbsp;Natural;<BR>
&nbsp;&nbsp;&nbsp;Null_Key&nbsp;:&nbsp;<B>constant</B>&nbsp;Key&nbsp;:=&nbsp;Key'First;<BR>
<B>end</B>&nbsp;Key_Manager;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT><B>package</B>&nbsp;<B>body</B>&nbsp;Key_Manager&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;Last_Key&nbsp;:&nbsp;Key&nbsp;:=&nbsp;Null_Key;<BR>
&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Get_Key(K&nbsp;:&nbsp;<B>out</B>&nbsp;Key)&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;<B>begin</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Last_Key&nbsp;:=&nbsp;Last_Key&nbsp;+&nbsp;1;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;K&nbsp;:=&nbsp;Last_Key;<BR>
&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;Get_Key;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;&quot;&lt;&quot;&nbsp;(X,&nbsp;Y&nbsp;:&nbsp;Key)&nbsp;<B>return</B>&nbsp;Boolean&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;<B>begin</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;Natural(X)&nbsp;&lt;&nbsp;Natural(Y);<BR>
&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;&quot;&lt;&quot;;<BR>
<B>end</B>&nbsp;Key_Manager;</TT></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>11&nbsp;&nbsp;<I>Notes on the example:</I>
Outside of the package Key_Manager, the operations available for objects
of type Key include assignment, the comparison for equality or inequality,
the procedure Get_Key and the operator &quot;&lt;&quot;; they do not
include other relational operators such as &quot;&gt;=&quot;, or arithmetic
operators.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>The explicitly declared operator &quot;&lt;&quot;
hides the predefined operator &quot;&lt;&quot; implicitly declared by
the <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>. Within
the body of the function, an explicit conversion of X and Y to the subtype
Natural is necessary to invoke the &quot;&lt;&quot; operator of the parent
type. Alternatively, the result of the function could be written as not
(X &gt;= Y), since the operator &quot;&gt;=&quot; is not redefined.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>The value of the variable Last_Key,
declared in the package body, remains unchanged between calls of the
procedure Get_Key. (See also the NOTES of <A HREF="AA-7-2.html">7.2</A>.)
</FONT></DIV>

<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>20.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The phrase in RM83-7.4.2(7), ``...after
the full type declaration'', doesn't work in the presence of child units,
so we define that rule in terms of visibility.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The definition of the Constrained
attribute for private types has been moved to ``Obsolescent Features.''
(The Constrained attribute of an object has not been moved there.) </FONT></DIV>

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