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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Incomplete Type Declarations</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-3-10.html">Previous</A> <A HREF="AA-3-10-2.html">Next</A></P>
<HR>
<H1> 3.10.1 Incomplete Type Declarations</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> There are no particular limitations on the designated
type of an access type. In particular, the type of a component of the
designated type can be another access type, or even the same access type.
This permits mutually dependent and recursive access types. An <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
can be used to introduce a type to be used as a designated type, while
deferring its full definition to a subsequent <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>.
</DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">incomplete_type_declaration<A NAME="I2177"></A>
::= </FONT><B>type</B> <A NAME="I2178"></A><FONT FACE="Arial, Helvetica">defining_identifier</FONT> [<A NAME="I2179"></A><FONT FACE="Arial, Helvetica">discriminant_part</FONT>];</DIV>
<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2180"></A>An <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
requires a completion, which shall be a <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>.
[If the <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
occurs immediately within either the visible part of a <FONT FACE="Arial, Helvetica">package_specification</FONT>
or a <FONT FACE="Arial, Helvetica">declarative_part</FONT>, then the
<FONT FACE="Arial, Helvetica">full_type_declaration</FONT> shall occur
later and immediately within this visible part or <FONT FACE="Arial, Helvetica">declarative_part</FONT>.
If the <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
occurs immediately within the private part of a given <FONT FACE="Arial, Helvetica">package_specification</FONT>,
then the <FONT FACE="Arial, Helvetica">full_type_declaration</FONT> shall
occur later and immediately within either the private part itself, or
the <FONT FACE="Arial, Helvetica">declarative_part</FONT> of the corresponding
<FONT FACE="Arial, Helvetica">package_body</FONT>.] </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Proof: </B>This is implied
by the next AARM-only rule, plus the rules in <A HREF="AA-3-11-1.html">3.11.1</A>,
``<A HREF="AA-3-11-1.html">Completions of Declarations</A>'' which require
a completion to appear later and immediately within the same declarative
region. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>If the <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
occurs immediately within the visible part of a <FONT FACE="Arial, Helvetica">package_specification</FONT>,
then the <FONT FACE="Arial, Helvetica">full_type_declaration</FONT> shall
occur immediately within this visible part. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>If the implementation
supports it, an <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
can be completed by a <FONT FACE="Arial, Helvetica">pragma</FONT> Import.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Normal"> If an <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
has a <FONT FACE="Arial, Helvetica">known_discriminant_part</FONT>, then
a <FONT FACE="Arial, Helvetica">full_type_declaration</FONT> that completes
it shall have a fully conforming (explicit) <FONT FACE="Arial, Helvetica">known_discriminant_part</FONT>
(see <A HREF="AA-6-3-1.html">6.3.1</A>). <A NAME="I2181"></A>[If an <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
has no <FONT FACE="Arial, Helvetica">discriminant_part</FONT> (or an
<FONT FACE="Arial, Helvetica">unknown_discriminant_part</FONT>), then
a corresponding <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>
is nevertheless allowed to have discriminants, either explicitly, or
inherited via derivation.]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> The only allowed
uses of a <FONT FACE="Arial, Helvetica">name</FONT> that denotes an <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
are as follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>No need to
say "prior to the end of the <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>"
since the name would not denote the <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
after the end of the <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>.
Also, with child library units, it would not be well defined whether
they come before or after the <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>
for deferred incomplete types. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>as the <FONT FACE="Arial, Helvetica">subtype_mark</FONT>
in the <FONT FACE="Arial, Helvetica">subtype_indication</FONT> of an
<FONT FACE="Arial, Helvetica">access_to_object_definition</FONT>; [the
only form of <FONT FACE="Arial, Helvetica">constraint</FONT> allowed
in this <FONT FACE="Arial, Helvetica">subtype_indication</FONT> is a
<FONT FACE="Arial, Helvetica">discriminant_constraint</FONT>;] </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>6.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>We
now allow <FONT FACE="Arial, Helvetica">discriminant_constraint</FONT>s
even if the full type is deferred to the package body. However, there
is no particular implementation burden because we have dropped the concept
of the dependent compatibility check. In other words, we have effectively
repealed AI83-00007. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>as the <FONT FACE="Arial, Helvetica">subtype_mark</FONT>
defining the subtype of a parameter or result of an <FONT FACE="Arial, Helvetica">access_to_subprogram_definition</FONT>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>7.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This allows, for
example, a record to have a component designating a subprogram that takes
that same record type as a parameter.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>as the <FONT FACE="Arial, Helvetica">subtype_mark</FONT>
in an <FONT FACE="Arial, Helvetica">access_definition</FONT>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>as the <FONT FACE="Arial, Helvetica">prefix</FONT> of an
<FONT FACE="Arial, Helvetica">attribute_reference</FONT> whose <FONT FACE="Arial, Helvetica">attribute_designator</FONT>
is Class; such an <FONT FACE="Arial, Helvetica">attribute_reference</FONT>
is similarly restricted to the uses allowed here; when used in this way,
the corresponding <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>
shall declare a tagged type, and the <FONT FACE="Arial, Helvetica">attribute_reference</FONT>
shall occur in the same library unit as the <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>9.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This is to prevent
children from imposing requirements on their ancestor library units for
deferred incomplete types.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal"> A dereference (whether implicit or explicit --
see <A HREF="AA-4-1.html">4.1</A>) shall not be of an incomplete type.
</DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2182"></A>An <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
declares an incomplete type and its first subtype; the first subtype
is unconstrained if a <FONT FACE="Arial, Helvetica">known_discriminant_part</FONT>
appears. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>If an <FONT FACE="Arial, Helvetica">unknown_discriminant_part</FONT>
or no <FONT FACE="Arial, Helvetica">discriminant_part</FONT> appears,
then the constrainedness of the first subtype doesn't matter for any
other rules or semantics, so we don't bother defining it. The case with
a <FONT FACE="Arial, Helvetica">known_discriminant_part</FONT> is the
only case in which a constraint could later be given in a <FONT FACE="Arial, Helvetica">subtype_indication</FONT>
naming the incomplete type. </FONT></DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2183"></A>The elaboration of an <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
has no effect. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>An incomplete type
has no real existence, so it doesn't need to be "created" in
the usual sense we do for other types. It is roughly equivalent to a
"forward;" declaration in Pascal. Private types are different,
because they have a different set of characteristics from their full
type. </FONT></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>80 <A NAME="I2184"></A>Within
a <FONT FACE="Arial, Helvetica">declarative_part</FONT>, an <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
and a corresponding <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>
cannot be separated by an intervening body. This is because a type has
to be completely defined before it is frozen, and a body freezes all
types declared prior to it in the same <FONT FACE="Arial, Helvetica">declarative_part</FONT>
(see <A HREF="AA-13-14.html">13.14</A>). </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
recursive type:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> Cell; <I>-- incomplete type declaration</I><BR>
<B>type</B> Link <B>is</B> <B>access</B> Cell;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> Cell <B>is</B><BR>
<B>record</B><BR>
Value : Integer;<BR>
Succ : Link;<BR>
Pred : Link;<BR>
<B>end</B> <B>record</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT>Head : Link := <B>new</B> Cell'(0, <B>null</B>, <B>null</B>);<BR>
Next : Link := Head.Succ;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Normal"> <I>Examples of mutually dependent access types:</I>
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> Person(<>); <I>-- incomplete type declaration</I><BR>
<B>type</B> Car; <I>-- incomplete type declaration</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> Person_Name <B>is</B> <B>access</B> Person;<BR>
<B>type</B> Car_Name <B>is</B> <B>access</B> <B>all</B> Car;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> Car <B>is</B><BR>
<B>record</B><BR>
Number : Integer;<BR>
Owner : Person_Name;<BR>
<B>end</B> <B>record</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> Person(Sex : Gender) <B>is</B><BR>
<B>record</B><BR>
Name : String(1 .. 20);<BR>
Birth : Date;<BR>
Age : Integer <B>range</B> 0 .. 130;<BR>
Vehicle : Car_Name;<BR>
<B>case</B> Sex <B>is</B><BR>
<B>when</B> M => Wife : Person_Name(Sex => F);<BR>
<B>when</B> F => Husband : Person_Name(Sex => M);<BR>
<B>end</B> <B>case</B>;<BR>
<B>end</B> <B>record</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Examples"><TT>My_Car, Your_Car, Next_Car : Car_Name := <B>new</B> Car; <I>-- see <A HREF="AA-4-8.html">4.8</A></I><BR>
George : Person_Name := <B>new</B> Person(M);<BR>
...<BR>
George.Vehicle := Your_Car;</TT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>23.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I2185"></A>The <FONT FACE="Arial, Helvetica">full_type_declaration</FONT>
that completes an <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
may have a <FONT FACE="Arial, Helvetica">known_discriminant_part</FONT>
even if the <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>
does not.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23.b/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>A <FONT FACE="Arial, Helvetica">discriminant_constraint</FONT>
may be applied to an incomplete type, even if <S>it </S>its completion
is deferred to the package body, because there is no ``dependent compatibility
check'' required any more. Of course, the constraint can be specified
only if a <FONT FACE="Arial, Helvetica">known_discriminant_part</FONT>
was given in the <FONT FACE="Arial, Helvetica">incomplete_type_declaration</FONT>.
As mentioned in the previous paragraph, that is no longer required even
when the full type has discriminants. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>23.c</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1>Dereferences
producing incomplete types were not explicitly disallowed in RM83, though
AI83-00039 indicated that it was not strictly necessary since troublesome
cases would result in Constraint_Error at run time, since the access
value would necessarily be null. However, this introduces an undesirable
implementation burden, as illustrated by Example 4 of AI83-00039: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23.d</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B> Pack <B>is</B><BR>
<B>type</B> Pri <B>is</B> <B>private</B>;<BR>
<B>private</B><BR>
<B>type</B> Sep;<BR>
<B>type</B> Pri <B>is</B> <B>access</B> Sep;<BR>
X : Pri;<BR>
<B>end</B> Pack;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23.e</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B> <B>body</B> Pack <B>is</B> --<I> Could be separately compiled!</I><BR>
<B>type</B> Sep <B>is</B> ...;<BR>
X := <B>new</B> Sep;<BR>
<B>end</B> Pack;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23.f</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>pragma</B> Elaborate(Pack);<BR>
<B>private</B> <B>package</B> Pack.Child <B>is</B><BR>
I : Integer := X.<B>all</B>'Size; --<I> Legal, by AI-00039.</I><BR>
<B>end</B> Pack.Child;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23.g</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Generating code for the above
example could be a serious implementation burden, since it would require
all aliased objects to store size dope, and for that dope to be in the
same format for all kinds of types (or some other equivalently inefficient
implementation). On the contrary, most implementations allocate dope
differently (or not at all) for different designated subtypes.</FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-3-10.html">Previous</A> <A HREF="AA-3-10-2.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|