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> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-7-3.html">Previous</A> <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"> [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"> 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 "+" 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"> {<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"> {<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"> {<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 "=" 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"> {<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"> 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> Parent <B>is</B><BR>
<B>type</B> Root <B>is</B> <B>tagged</B> <B>null</B> <B>record</B>;<BR>
<B>procedure</B> Op1(X : Root);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.e</FONT></DIV>
<DIV Class="SmallExamples"><TT> <B>type</B> My_Int <B>is</B> <B>range</B> 1..10;<BR>
<B>private</B><BR>
<B>procedure</B> Op2(X : Root);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.f</FONT></DIV>
<DIV Class="SmallExamples"><TT> <B>type</B> Another_Int <B>is</B> <B>new</B> My_Int;<BR>
<B>procedure</B> Int_Op(X : My_Int);<BR>
<B>end</B> Parent;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.g</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>with</B> Parent; <B>use</B> Parent;<BR>
<B>package</B> Unrelated <B>is</B><BR>
<B>type</B> T2 <B>is</B> <B>new</B> Root <B>with</B> <B>null</B> <B>record</B>;<BR>
<B>procedure</B> Op2(X : T2);<BR>
<B>end</B> Unrelated;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.h</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B> Parent.Child <B>is</B><BR>
<B>type</B> T3 <B>is</B> <B>new</B> Root <B>with</B> <B>null</B> <B>record</B>;<BR>
--<I> Op1(T3) implicitly declared here.</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.i</FONT></DIV>
<DIV Class="SmallExamples"><TT> <B>package</B> Nested <B>is</B><BR>
<B>type</B> T4 <B>is</B> <B>new</B> Root <B>with</B> <B>null</B> <B>record</B>;<BR>
<B>private</B><BR>
...<BR>
<B>end</B> Nested;<BR>
<B>private</B><BR>
--<I> Op2(T3) implicitly declared here.</I><BR>
...<BR>
<B>end</B> Parent.Child;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.j</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>with</B> Unrelated; <B>use</B> Unrelated;<BR>
<B>package</B> <B>body</B> Parent.Child <B>is</B><BR>
<B>package</B> <B>body</B> Nested <B>is</B><BR>
--<I> Op2(T4) implicitly declared here.</I><BR>
<B>end</B> Nested;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.k</FONT></DIV>
<DIV Class="SmallExamples"><TT> <B>type</B> T5 <B>is</B> <B>new</B> T2 <B>with</B> <B>null</B> <B>record</B>;<BR>
<B>end</B> 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> P <B>is</B><BR>
<B>type</B> Comp1 <B>is</B> <B>private</B>;<BR>
<B>private</B><BR>
<B>type</B> Comp1 <B>is</B> <B>new</B> Boolean;<BR>
<B>end</B> P;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.u</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B> P.Q <B>is</B><BR>
<B>package</B> R <B>is</B><BR>
<B>type</B> Comp2 <B>is</B> <B>limited</B> <B>private</B>;<BR>
<B>type</B> A <B>is</B> <B>array</B>(Integer <B>range</B> <>) <B>of</B> Comp2;<BR>
<B>private</B><BR>
<B>type</B> Comp2 <B>is</B> <B>new</B> Comp1;<BR>
--<I> A becomes nonlimited here.</I><BR>
--<I> "="(A, A) return Boolean is implicitly declared here.</I><BR>
...<BR>
<B>end</B> R;<BR>
<B>private</B><BR>
--<I> Now we find out what Comp1 really is, which reveals</I><BR>
--<I> more information about Comp2, but we're not within</I><BR>
--<I> the immediate scope of Comp2, so we don't do anything</I><BR>
--<I> about it yet.</I><BR>
<B>end</B> P.Q;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.v</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B> <B>body</B> P.Q <B>is</B><BR>
<B>package</B> <B>body</B> R <B>is</B><BR>
--<I> Things like "<B>xor</B>"(A,A) return A are implicitly</I><BR>
--<I> declared here.</I><BR>
<B>end</B> R;<BR>
<B>end</B> 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> Outer <B>is</B><BR>
<B>package</B> Inner <B>is</B><BR>
<B>type</B> Inner_Type <B>is</B> <B>private</B>;<BR>
<B>private</B><BR>
<B>type</B> Inner_Type <B>is</B> <B>new</B> Boolean;<BR>
<B>end</B> Inner;<BR>
<B>type</B> Outer_Type <B>is</B> <B>array</B>(Natural <B>range</B> <>) <B>of</B> Inner.Inner_Type;<BR>
<B>end</B> Outer;</U></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.v.3/1</FONT></DIV>
<DIV Class="SmallExamples"><TT><U><B>package</B> <B>body</B> Outer <B>is</B><BR>
<B>package</B> <B>body</B> Inner <B>is</B><BR>
-- At this point, we can see that Inner_Type is a Boolean type.<BR>
-- But we don't want Outer_Type to gain an "and" operator here.<BR>
<B>end</B> Inner;<BR>
<B>end</B> Outer;</U></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> [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> 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 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 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 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"> <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> Key_Manager <B>is</B><BR>
<B>type</B> Key <B>is</B> <B>private</B>;<BR>
Null_Key : <B>constant</B> Key; --<I> a deferred constant declaration (see <A HREF="AA-7-4.html">7.4</A>)</I><BR>
<B>procedure</B> Get_Key(K : <B>out</B> Key);<BR>
<B>function</B> "<" (X, Y : Key) <B>return</B> Boolean;<BR>
<B>private</B><BR>
<B>type</B> Key <B>is</B> <B>new</B> Natural;<BR>
Null_Key : <B>constant</B> Key := Key'First;<BR>
<B>end</B> Key_Manager;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT><B>package</B> <B>body</B> Key_Manager <B>is</B><BR>
Last_Key : Key := Null_Key;<BR>
<B>procedure</B> Get_Key(K : <B>out</B> Key) <B>is</B><BR>
<B>begin</B><BR>
Last_Key := Last_Key + 1;<BR>
K := Last_Key;<BR>
<B>end</B> Get_Key;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<" (X, Y : Key) <B>return</B> Boolean <B>is</B><BR>
<B>begin</B><BR>
<B>return</B> Natural(X) < Natural(Y);<BR>
<B>end</B> "<";<BR>
<B>end</B> 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 <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 "<"; they do not
include other relational operators such as ">=", or arithmetic
operators.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>The explicitly declared operator "<"
hides the predefined operator "<" 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 "<" operator of the parent
type. Alternatively, the result of the function could be written as not
(X >= Y), since the operator ">=" 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> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-7-3.html">Previous</A> <A HREF="AA-7-4.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|