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 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Array Aggregates</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-4-3-2.html">Previous</A> <A HREF="AA-4-4.html">Next</A></P>
<HR>
<H1> 4.3.3 Array Aggregates</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [In an <FONT FACE="Arial, Helvetica">array_aggregate</FONT>,
a value is specified for each component of an array, either positionally
or by its index.] For a <FONT FACE="Arial, Helvetica">positional_array_aggregate</FONT>,
the components are given in increasing-index order, with a final <B>others</B>,
if any, representing any remaining components. For a <FONT FACE="Arial, Helvetica">named_array_aggregate</FONT>,
the components are identified by the values covered by the <FONT FACE="Arial, Helvetica">discrete_choice</FONT>s.</DIV>
<H4 ALIGN=CENTER>Language Design Principles</H4>
<DIV Class="Paranum"><FONT SIZE=-2>1.a/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The rules in this subclause are
based on terms and rules for <FONT FACE="Arial, Helvetica">discrete_choice_list</FONT>s
defined in <A HREF="AA-3-8-1.html">3.8.1</A>, ``<A HREF="AA-3-8-1.html">Variant
Parts and Discrete Choices</A>''. <U>For example, the requirements that
<B>others</B> come last and stand alone are found there.</U> </FONT></DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">array_aggregate<A NAME="I2402"></A>
::= </FONT><BR>
<A NAME="I2403"></A><FONT FACE="Arial, Helvetica">positional_array_aggregate</FONT> | <A NAME="I2404"></A><FONT FACE="Arial, Helvetica">named_array_aggregate</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">positional_array_aggregate<A NAME="I2405"></A>
::= </FONT><BR>
(<A NAME="I2406"></A><FONT FACE="Arial, Helvetica">expression</FONT>, <A NAME="I2407"></A><FONT FACE="Arial, Helvetica">expression</FONT> {, <A NAME="I2408"></A><FONT FACE="Arial, Helvetica">expression</FONT>})<BR>
| (<A NAME="I2409"></A><FONT FACE="Arial, Helvetica">expression</FONT> {, <A NAME="I2410"></A><FONT FACE="Arial, Helvetica">expression</FONT>}, <B>others</B> => <A NAME="I2411"></A><FONT FACE="Arial, Helvetica">expression</FONT>)</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">named_array_aggregate<A NAME="I2412"></A>
::= </FONT><BR>
(<A NAME="I2413"></A><FONT FACE="Arial, Helvetica">array_component_association</FONT> {, <A NAME="I2414"></A><FONT FACE="Arial, Helvetica">array_component_association</FONT>})</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">array_component_association<A NAME="I2415"></A>
::= </FONT><BR>
<A NAME="I2416"></A><FONT FACE="Arial, Helvetica">discrete_choice_list</FONT> => <A NAME="I2417"></A><FONT FACE="Arial, Helvetica">expression</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2418"></A>An <I>n-dimensional</I> <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
is one that is written as n levels of nested <FONT FACE="Arial, Helvetica">array_aggregate</FONT>s
(or at the bottom level, equivalent <FONT FACE="Arial, Helvetica">string_literal</FONT>s).
<A NAME="I2419"></A>For the multidimensional case (n >= 2) the <FONT FACE="Arial, Helvetica">array_aggregate</FONT>s
(or equivalent <FONT FACE="Arial, Helvetica">string_literal</FONT>s)
at the n-1 lower levels are called <I>subaggregate</I>s of the enclosing
n-dimensional <FONT FACE="Arial, Helvetica">array_aggregate</FONT>. <A NAME="I2420"></A>The
<FONT FACE="Arial, Helvetica">expression</FONT>s of the bottom level
subaggregates (or of the <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
itself if one-dimensional) are called the <I>array component expressions</I>
of the enclosing n-dimensional <FONT FACE="Arial, Helvetica">array_aggregate</FONT>.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Subaggregates
do not have a type. They correspond to part of an array. For example,
with a matrix, a subaggregate would correspond to a single row of the
matrix. The definition of "n-dimensional" <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
applies to subaggregates as well as <FONT FACE="Arial, Helvetica">aggregate</FONT>s
that have a type. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B><A NAME="I2421"></A>An
<I><B>others</B> choice</I> is the reserved word <B>others</B> as it
appears in a <FONT FACE="Arial, Helvetica">positional_array_aggregate</FONT>
or as the <FONT FACE="Arial, Helvetica">discrete_choice</FONT> of the
<FONT FACE="Arial, Helvetica">discrete_choice_list</FONT> in an <FONT FACE="Arial, Helvetica">array_component_association</FONT>.
</FONT></DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2422"></A>The expected type for an <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
(that is not a subaggregate) shall be a single nonlimited array type.
<A NAME="I2423"></A>The component type of this array type is the expected
type for each array component expression of the <FONT FACE="Arial, Helvetica">array_aggregate</FONT>.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>We already
require a single array or record type or record extension for an <FONT FACE="Arial, Helvetica">aggregate</FONT>.
The above rule requiring a single nonlimited array type (and similar
ones for record and extension aggregates) resolves which kind of aggregate
you have. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2424"></A>The expected type for each
<FONT FACE="Arial, Helvetica">discrete_choice</FONT> in any <FONT FACE="Arial, Helvetica">discrete_choice_list</FONT>
of a <FONT FACE="Arial, Helvetica">named_array_aggregate</FONT> is the
type of the <I>corresponding index</I>; <A NAME="I2425"></A>the corresponding
index for an <FONT FACE="Arial, Helvetica">array_aggregate</FONT> that
is not a subaggregate is the first index of its type; for an (n-m)-dimensional
subaggregate within an <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
of an n-dimensional type, the corresponding index is the index in position
m+1. </DIV>
<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal"> An <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
of an n-dimensional array type shall be written as an n-dimensional <FONT FACE="Arial, Helvetica">array_aggregate</FONT>.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>In an m-dimensional
<FONT FACE="Arial, Helvetica">array_aggregate</FONT> [(including a subaggregate)],
where m >= 2, each of the <FONT FACE="Arial, Helvetica">expression</FONT>s
has to be an (m-1)-dimensional subaggregate. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> An <B>others</B>
choice is allowed for an <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
only if an <I>applicable index constraint</I> applies to the <FONT FACE="Arial, Helvetica">array_aggregate</FONT>.
<A NAME="I2426"></A>[An applicable index constraint is a constraint provided
by certain contexts where an <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
is permitted that can be used to determine the bounds of the array value
specified by the aggregate.] Each of the following contexts (and none
other) defines an applicable index constraint: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For an <FONT FACE="Arial, Helvetica">explicit_actual_parameter</FONT>,
an <FONT FACE="Arial, Helvetica">explicit_generic_actual_parameter</FONT>,
the <FONT FACE="Arial, Helvetica">expression</FONT> of a <FONT FACE="Arial, Helvetica">return_statement</FONT>,
the initialization expression in an <FONT FACE="Arial, Helvetica">object_declaration</FONT>,
or a <FONT FACE="Arial, Helvetica">default_expression</FONT> [(for a
parameter or a component)], when the nominal subtype of the corresponding
formal parameter, generic formal parameter, function result, object,
or component is a constrained array subtype, the applicable index constraint
is the constraint of the subtype;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For the <FONT FACE="Arial, Helvetica">expression</FONT>
of an <FONT FACE="Arial, Helvetica">assignment_statement</FONT> where
the <FONT FACE="Arial, Helvetica">name</FONT> denotes an array variable,
the applicable index constraint is the constraint of the array variable;
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This case is broken
out because the constraint comes from the actual subtype of the variable
(which is always constrained) rather than its nominal subtype (which
might be unconstrained). </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For the operand of a <FONT FACE="Arial, Helvetica">qualified_expression</FONT>
whose <FONT FACE="Arial, Helvetica">subtype_mark</FONT> denotes a constrained
array subtype, the applicable index constraint is the constraint of the
subtype;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For a component <FONT FACE="Arial, Helvetica">expression</FONT>
in an <FONT FACE="Arial, Helvetica">aggregate</FONT>, if the component's
nominal subtype is a constrained array subtype, the applicable index
constraint is the constraint of the subtype; </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>14.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>Here, the <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
with <B>others</B> is being used within a larger aggregate. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For a parenthesized <FONT FACE="Arial, Helvetica">expression</FONT>,
the applicable index constraint is that, if any, defined for the <FONT FACE="Arial, Helvetica">expression</FONT>.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>15.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>RM83 omitted
this case, presumably as an oversight. We want to minimize situations
where an <FONT FACE="Arial, Helvetica">expression</FONT> becomes illegal
if parenthesized. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Normal"> The applicable index constraint <I>applies</I>
to an <FONT FACE="Arial, Helvetica">array_aggregate</FONT> that appears
in such a context, as well as to any subaggregates thereof. In the case
of an <FONT FACE="Arial, Helvetica">explicit_actual_parameter</FONT>
(or <FONT FACE="Arial, Helvetica">default_expression</FONT>) for a call
on a generic formal subprogram, no applicable index constraint is defined.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This avoids generic
contract model problems, because only mode conformance is required when
matching actual subprograms with generic formal subprograms. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Normal"> The <FONT FACE="Arial, Helvetica">discrete_choice_list</FONT>
of an <FONT FACE="Arial, Helvetica">array_component_association</FONT>
is allowed to have a <FONT FACE="Arial, Helvetica">discrete_choice</FONT>
that is a nonstatic <FONT FACE="Arial, Helvetica">expression</FONT> or
that is a <FONT FACE="Arial, Helvetica">discrete_range</FONT> that defines
a nonstatic or null range, only if it is the single <FONT FACE="Arial, Helvetica">discrete_choice</FONT>
of its <FONT FACE="Arial, Helvetica">discrete_choice_list</FONT>, and
there is only one <FONT FACE="Arial, Helvetica">array_component_association</FONT>
in the <FONT FACE="Arial, Helvetica">array_aggregate</FONT>. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>We now allow
a nonstatic <B>others</B> choice even if there are other array component
expressions as well. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Normal"> In a <FONT FACE="Arial, Helvetica">named_array_aggregate</FONT>
with more than one <FONT FACE="Arial, Helvetica">discrete_choice</FONT>,
no two <FONT FACE="Arial, Helvetica">discrete_choice</FONT>s are allowed
to cover the same value (see <A HREF="AA-3-8-1.html">3.8.1</A>); if there
is no <B>others</B> choice, the <FONT FACE="Arial, Helvetica">discrete_choice</FONT>s
taken together shall exactly cover a contiguous sequence of values of
the corresponding index type. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>This implies
that each component must be specified exactly once. See AI83-309. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Normal"> A bottom level subaggregate of a multidimensional
<FONT FACE="Arial, Helvetica">array_aggregate</FONT> of a given array
type is allowed to be a <FONT FACE="Arial, Helvetica">string_literal</FONT>
only if the component type of the array type is a character type; each
character of such a <FONT FACE="Arial, Helvetica">string_literal</FONT>
shall correspond to a <FONT FACE="Arial, Helvetica">defining_character_literal</FONT>
of the component type. </DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Normal"> A subaggregate that is a <FONT FACE="Arial, Helvetica">string_literal</FONT>
is equivalent to one that is a <FONT FACE="Arial, Helvetica">positional_array_aggregate</FONT>
of the same length, with each <FONT FACE="Arial, Helvetica">expression</FONT>
being the <FONT FACE="Arial, Helvetica">character_literal</FONT> for
the corresponding character of the <FONT FACE="Arial, Helvetica">string_literal</FONT>.
</DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <A NAME="I2427"></A>The
evaluation of an <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
of a given array type proceeds in two steps: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DL Class="Enumerated"><DT> 1.<DD Class="Enumerated">
Any <FONT FACE="Arial, Helvetica">discrete_choice</FONT>s of this aggregate
and of its subaggregates are evaluated in an arbitrary order, and converted
to the corresponding index type; <A NAME="I2428"></A></DL>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DL Class="Enumerated"><DT> 2.<DD Class="Enumerated">
The array component expressions of the aggregate are evaluated in an
arbitrary order and their values are converted to the component subtype
of the array type; an array component expression is evaluated once for
each associated component. <A NAME="I2429"></A></DL>
<DIV Class="Paranum"><FONT SIZE=-2>23.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Subaggregates
are not separately evaluated. The conversion of the value of the component
expressions to the component subtype might raise Constraint_Error. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <A NAME="I2430"></A>The
bounds of the index range of an <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
[(including a subaggregate)] are determined as follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For an <FONT FACE="Arial, Helvetica">array_aggregate</FONT>
with an <B>others</B> choice, the bounds are those of the corresponding
index range from the applicable index constraint;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For a <FONT FACE="Arial, Helvetica">positional_array_aggregate</FONT>
[(or equivalent <FONT FACE="Arial, Helvetica">string_literal</FONT>)]
without an <B>others</B> choice, the lower bound is that of the corresponding
index range in the applicable index constraint, if defined, or that of
the corresponding index subtype, if not; in either case, the upper bound
is determined from the lower bound and the number of <FONT FACE="Arial, Helvetica">expression</FONT>s
[(or the length of the <FONT FACE="Arial, Helvetica">string_literal</FONT>)];</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For a <FONT FACE="Arial, Helvetica">named_array_aggregate</FONT>
without an <B>others</B> choice, the bounds are determined by the smallest
and largest index values covered by any <FONT FACE="Arial, Helvetica">discrete_choice_list</FONT>.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>27.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>We don't need to
say that each index value has to be covered exactly once, since that
is a ramification of the general rule on <FONT FACE="Arial, Helvetica">aggregate</FONT>s
that each component's value has to be specified exactly once. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2431"></A><A NAME="I2432"></A>For an
<FONT FACE="Arial, Helvetica">array_aggregate</FONT>, a check is made
that the index range defined by its bounds is compatible with the corresponding
index subtype. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>In RM83, this
was phrased more explicitly, but once we define "compatibility"
between a range and a subtype, it seems to make sense to take advantage
of that definition. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The definition
of compatibility handles the special case of a null range, which is always
compatible with a subtype. See AI83-00313. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2433"></A><A NAME="I2434"></A>For an
<FONT FACE="Arial, Helvetica">array_aggregate</FONT> with an <B>others</B>
choice, a check is made that no <FONT FACE="Arial, Helvetica">expression</FONT>
is specified for an index value outside the bounds determined by the
applicable index constraint. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>RM83 omitted
this case, apparently through an oversight. AI83-00309 defines this as
a dynamic check, even though other Ada 83 rules ensured that this check
could be performed statically. We now allow an <B>others</B> choice to
be dynamic, even if it is not the only choice, so this check now needs
to be dynamic, in some cases. Also, within a generic unit, this would
be a nonstatic check in some cases. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2435"></A><A NAME="I2436"></A>For a
multidimensional <FONT FACE="Arial, Helvetica">array_aggregate</FONT>,
a check is made that all subaggregates that correspond to the same index
have the same bounds. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>No array
bounds ``sliding'' is performed on subaggregates. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>If sliding were
performed, it would not be obvious which subaggregate would determine
the bounds of the corresponding index. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2437"></A>The exception Constraint_Error
is raised if any of the above checks fail. </DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>10 In an <FONT FACE="Arial, Helvetica">array_aggregate</FONT>,
positional notation may only be used with two or more <FONT FACE="Arial, Helvetica">expression</FONT>s;
a single <FONT FACE="Arial, Helvetica">expression</FONT> in parentheses
is interpreted as a <FONT FACE="Arial, Helvetica">parenthesized_expression</FONT>.
A <FONT FACE="Arial, Helvetica">named_array_aggregate</FONT>, such as
(1 => X), may be used to specify an array with a single component.
</FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Examples of
array aggregates with positional associations:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<DIV Class="Examples"><TT>(7, 9, 5, 1, 3, 2, 4, 8, 6, 0)<BR>
Table'(5, 8, 4, 1, <B>others</B> => 0) <I>-- see <A HREF="AA-3-6.html">3.6</A> </I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em"> <I>Examples of array
aggregates with named associations:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36</FONT></DIV>
<DIV Class="Examples"><TT>(1 .. 5 => (1 .. 8 => 0.0)) <I>-- two-dimensional</I><BR>
(1 .. N => <B>new</B> Cell) <I>-- N new cells, in particular for N = 0</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<DIV Class="Examples"><TT>Table'(2 | 4 | 10 => 1, <B>others</B> => 0)<BR>
Schedule'(Mon .. Fri => True, <B>others</B> => False) <I>-- see <A HREF="AA-3-6.html">3.6</A></I><BR>
Schedule'(Wed | Sun => False, <B>others</B> => True)<BR>
Vector'(1 => 2.5) <I>-- single-component vector</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em"> <I>Examples of two-dimensional
array aggregates:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Examples"><TT><I>-- Three aggregates for the same value of subtype Matrix(1..2,1..3) (see <A HREF="AA-3-6.html">3.6</A>):</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="Examples"><TT>((1.1, 1.2, 1.3), (2.1, 2.2, 2.3))<BR>
(1 => (1.1, 1.2, 1.3), 2 => (2.1, 2.2, 2.3))<BR>
(1 => (1 => 1.1, 2 => 1.2, 3 => 1.3), 2 => (1 => 2.1, 2 => 2.2, 3 => 2.3))</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>41</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em"> <I>Examples of aggregates
as initial values:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>42</FONT></DIV>
<DIV Class="Examples"><TT>A : Table := (7, 9, 5, 1, 3, 2, 4, 8, 6, 0); <I>-- A(1)=7, A(10)=0</I><BR>
B : Table := (2 | 4 | 10 => 1, <B>others</B> => 0); <I>-- B(1)=0, B(10)=1</I><BR>
C : <B>constant</B> Matrix := (1 .. 5 => (1 .. 8 => 0.0)); <I>-- C'Last(1)=5, C'Last(2)=8</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43</FONT></DIV>
<DIV Class="Examples"><TT>D : Bit_Vector(M .. N) := (M .. N => True); <I>-- see <A HREF="AA-3-6.html">3.6</A></I><BR>
E : Bit_Vector(M .. N) := (<B>others</B> => True);<BR>
F : String(1 .. 1) := (1 => 'F'); <I>-- a one component aggregate: same as "F"</I></TT></DIV>
<H4 ALIGN=CENTER>Incompatibilities With Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>43.a.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><U><A NAME="I2438"></A>In Ada
95, no applicable index constraint is defined for a parameter in a call
to a generic formal subprogram; thus, some aggregates that are legal
in Ada 83 are illegal in Ada 95. For example:</U> </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43.a.2/1</FONT></DIV>
<DIV Class="SmallExamples"><TT><U><B>subtype</B> S3 <B>is</B> String (1 .. 3);<BR>
...<BR>
<B>generic</B><BR>
<B>with function</B> F (The_S3 : <B>in</B> S3) <B>return</B> Integer;<BR>
<B>package</B> Gp <B>is</B><BR>
I : constant Integer := F ((1 => '!', others => '?'));<BR>
-- <I>The aggregate is legal in Ada 83, illegal in Ada 95.</I><BR>
<B>end</B> Gp;</U></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43.a.3/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><U>This change eliminates generic
contract model problems.</U> </FONT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>43.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I2439"></A>We now allow
"named with others" aggregates in all contexts where there
is an applicable index constraint, effectively eliminating what was RM83-4.3.2(6).
Sliding never occurs on an aggregate with others, because its bounds
come from the applicable index constraint, and therefore already match
the bounds of the target.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The legality of an <B>others</B>
choice is no longer affected by the staticness of the applicable index
constraint. This substantially simplifies several rules, while being
slightly more flexible for the user. It obviates the rulings of AI83-00244
and AI83-00310, while taking advantage of the dynamic nature of the "extra
values" check required by AI83-00309.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Named array aggregates are permitted
even if the index type is descended from a formal scalar type. See <A HREF="AA-4-9.html">4.9</A>
and AI83-00190. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>43.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We now separate named and positional
array aggregate syntax, since, unlike other aggregates, named and positional
associations cannot be mixed in array aggregates (except that an <B>others</B>
choice is allowed in a positional array aggregate).</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43.e</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We have also reorganized the presentation
to handle multidimensional and one-dimensional aggregates more uniformly,
and to incorporate the rulings of AI83-00019, AI83-00309, etc. </FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-4-3-2.html">Previous</A> <A HREF="AA-4-4.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|