File: AA-3-6.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 (367 lines) | stat: -rw-r--r-- 29,220 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>AARM95 - Array Types</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-3-5-10.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-3-6-1.html">Next</A></P>
<HR>
<H1> 3.6 Array Types</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I1829"></A><A NAME="I1830"></A>An <I>array</I>
object is a composite object consisting of components which all have
the same subtype. The name for a component of an array uses one or more
index values belonging to specified discrete types. The value of an array
object is a composite value consisting of the values of the components.
</DIV>

<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">array_type_definition<A NAME="I1831"></A>
::= </FONT><BR>
&nbsp;&nbsp;&nbsp;<A NAME="I1832"></A><FONT FACE="Arial, Helvetica">unconstrained_array_definition</FONT>&nbsp;|&nbsp;<A NAME="I1833"></A><FONT FACE="Arial, Helvetica">constrained_array_definition</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">unconstrained_array_definition<A NAME="I1834"></A>
::= </FONT><BR>
&nbsp;&nbsp;&nbsp;<B>array</B>(<A NAME="I1835"></A><FONT FACE="Arial, Helvetica">index_subtype_definition</FONT>&nbsp;{,&nbsp;<A NAME="I1836"></A><FONT FACE="Arial, Helvetica">index_subtype_definition</FONT>})&nbsp;<B>of</B>&nbsp;<A NAME="I1837"></A><FONT FACE="Arial, Helvetica">component_definition</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">index_subtype_definition<A NAME="I1838"></A>
::= </FONT><A NAME="I1839"></A><FONT FACE="Arial, Helvetica">subtype_mark</FONT>&nbsp;<B>range</B>&nbsp;&lt;&gt;</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">constrained_array_definition<A NAME="I1840"></A>
::= </FONT><BR>
&nbsp;&nbsp;&nbsp;<B>array</B>&nbsp;(<A NAME="I1841"></A><FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>&nbsp;{,&nbsp;<A NAME="I1842"></A><FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>})&nbsp;<B>of</B>&nbsp;<A NAME="I1843"></A><FONT FACE="Arial, Helvetica">component_definition</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">discrete_subtype_definition<A NAME="I1844"></A>
::= </FONT><I>discrete_</I><A NAME="I1845"></A><FONT FACE="Arial, Helvetica">subtype_indication</FONT>&nbsp;|&nbsp;<A NAME="I1846"></A><FONT FACE="Arial, Helvetica">range</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">component_definition<A NAME="I1847"></A>
::= </FONT>[<B>aliased</B>]&nbsp;<A NAME="I1848"></A><FONT FACE="Arial, Helvetica">subtype_indication</FONT></DIV>

<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I1849"></A>For a <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>
that is a <FONT FACE="Arial, Helvetica">range</FONT>, the <FONT FACE="Arial, Helvetica">range</FONT>
shall resolve to be of some specific discrete type[; which discrete type
shall be determined without using any context other than the bounds of
the <FONT FACE="Arial, Helvetica">range</FONT> itself (plus the preference
for <I>root_integer</I> -- see <A HREF="AA-8-6.html">8.6</A>).] </DIV>

<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I1850"></A>Each <FONT FACE="Arial, Helvetica">index_subtype_definition</FONT>
or <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT> in
an <FONT FACE="Arial, Helvetica">array_type_definition</FONT> defines
an <I>index subtype</I>; <A NAME="I1851"></A>its type (the <I>index type</I>)
shall be discrete. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B><A NAME="I1852"></A>An
<I>index</I> is a discrete quantity used to select along a given dimension
of an array. A component is selected by specifying corresponding values
for each of the indices. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I1853"></A>The subtype defined by the
<FONT FACE="Arial, Helvetica">subtype_indication</FONT> of a <FONT FACE="Arial, Helvetica">component_definition</FONT>
(the <I>component subtype</I>) shall be a definite subtype. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>This applies
to all uses of <FONT FACE="Arial, Helvetica">component_definition</FONT>,
including in <FONT FACE="Arial, Helvetica">record_type_definition</FONT>s
and <FONT FACE="Arial, Helvetica">protected_definition</FONT>s.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;Within the definition of a nonlimited composite
type (or a limited composite type that later in its immediate scope becomes
nonlimited -- see <A HREF="AA-7-3-1.html">7.3.1</A> and <A HREF="AA-7-5.html">7.5</A>),
if a <FONT FACE="Arial, Helvetica">component_definition</FONT> contains
the reserved word <B>aliased</B> and the type of the component is discriminated,
then the nominal subtype of the component shall be constrained. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>If we allowed the
subtype to be unconstrained, then the discriminants might change because
of an assignment to the containing (nonlimited) object, thus causing
a potential violation of an access subtype constraint of an access value
designating the aliased component.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that the rule elsewhere defining
all aliased discriminated objects to be constrained does not help --
that rule prevents assignments to the component itself from doing any
harm, but not assignments to the containing object.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.c</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1>We
allow this for components within limited types since assignment to the
enclosing object is not a problem. Furthermore, it is important to be
able to use a default expression for a discriminant in arrays of limited
components, since that is the only way to give the components different
values for their discriminants. For example: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.d</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>protected</B>&nbsp;<B>type</B>&nbsp;Counter_Type(Initial_Value&nbsp;:&nbsp;Integer&nbsp;:=&nbsp;1)&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Get_Next(Next_Value&nbsp;:&nbsp;<B>out</B>&nbsp;Integer);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;Returns&nbsp;the&nbsp;next&nbsp;value&nbsp;on&nbsp;each&nbsp;call,&nbsp;bumping&nbsp;Count</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<I>&nbsp;before&nbsp;returning.</I><BR>
<B>private</B><BR>
&nbsp;&nbsp;&nbsp;Count&nbsp;:&nbsp;Integer&nbsp;:=&nbsp;Initial_Value;<BR>
<B>end</B>&nbsp;Counter_Type;<BR>
<B>protected</B>&nbsp;<B>body</B>&nbsp;Counter_Type&nbsp;<B>is</B>&nbsp;...</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.e</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>function</B>&nbsp;Next_Id(Counter&nbsp;:&nbsp;<B>access</B>&nbsp;Counter_Type)&nbsp;<B>return</B>&nbsp;Integer&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:&nbsp;Integer;<BR>
<B>begin</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;Counter.Get_Next(Result);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;Result;<BR>
<B>end</B>&nbsp;Next_Id;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.f</FONT></DIV>
<DIV Class="SmallExamples"><TT>C&nbsp;:&nbsp;<B>aliased</B>&nbsp;Counter_Type;<BR>
<B>task</B>&nbsp;<B>type</B>&nbsp;T(Who_Am_I&nbsp;:&nbsp;Integer&nbsp;:=&nbsp;Next_Id(C'Access));<BR>
<B>task</B>&nbsp;<B>body</B>&nbsp;T&nbsp;<B>is</B>&nbsp;...</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.g</FONT></DIV>
<DIV Class="SmallExamples"><TT>Task_Array&nbsp;:&nbsp;<B>array</B>(1..100)&nbsp;<B>of</B>&nbsp;<B>aliased</B>&nbsp;T;<BR>
&nbsp;&nbsp;--<I>&nbsp;Array&nbsp;of&nbsp;task&nbsp;elements,&nbsp;each&nbsp;with&nbsp;its&nbsp;own&nbsp;unique&nbsp;ID.</I><BR>
&nbsp;&nbsp;--<I>&nbsp;We&nbsp;specify&nbsp;&quot;aliased&quot;&nbsp;so&nbsp;we&nbsp;can&nbsp;use&nbsp;Task_Array(I)'Access.</I><BR>
&nbsp;&nbsp;--<I>&nbsp;This&nbsp;is&nbsp;safe&nbsp;because&nbsp;Task_Array&nbsp;is&nbsp;of&nbsp;a&nbsp;limited&nbsp;type,</I><BR>
&nbsp;&nbsp;--<I>&nbsp;so&nbsp;there&nbsp;is&nbsp;no&nbsp;way&nbsp;an&nbsp;assignment&nbsp;to&nbsp;it&nbsp;could&nbsp;change</I><BR>
&nbsp;&nbsp;--<I>&nbsp;the&nbsp;discriminants&nbsp;of&nbsp;one&nbsp;of&nbsp;its&nbsp;components.</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.h</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Note that
this rule applies to array components and record components, but not
to protected type components (since they are always limited). </FONT></DIV>

<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I1854"></A><A NAME="I1855"></A><A NAME="I1856"></A>An
array is characterized by the number of indices (the <I>dimensionality</I>
of the array), the type and position of each index, the lower and upper
bounds for each index, and the subtype of the components. The order of
the indices is significant.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;A one-dimensional array has a distinct component
for each possible index value. A multidimensional array has a distinct
component for each possible sequence of index values that can be formed
by selecting one value for each index position (in the given order).
The possible values for a given index are all the values between the
lower and upper bounds, inclusive; <A NAME="I1857"></A>this range of
values is called the <I>index range</I>. <A NAME="I1858"></A>The <I>bounds</I>
of an array are the bounds of its index ranges. <A NAME="I1859"></A>The
<I>length</I> of a dimension of an array is the number of values of the
index range of the dimension (zero for a null range). <A NAME="I1860"></A>The
<I>length</I> of a one-dimensional array is the length of its only dimension.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;An <FONT FACE="Arial, Helvetica">array_type_definition</FONT>
defines an array type and its first subtype. For each object of this
array type, the number of indices, the type and position of each index,
and the subtype of the components are as in the type definition[; the
values of the lower and upper bounds for each index belong to the corresponding
index subtype of its type, except for null arrays (see <A HREF="AA-3-6-1.html">3.6.1</A>)].</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I1861"></A><A NAME="I1862"></A>An <FONT FACE="Arial, Helvetica">unconstrained_array_definition</FONT>
defines an array type with an unconstrained first subtype. Each <FONT FACE="Arial, Helvetica">index_subtype_definition</FONT>
defines the corresponding index subtype to be the subtype denoted by
the <FONT FACE="Arial, Helvetica">subtype_mark</FONT>. [<A NAME="I1863"></A>
The compound delimiter &lt;&gt; (called a <I>box</I>) of an <FONT FACE="Arial, Helvetica">index_subtype_definition</FONT>
stands for an undefined range (different objects of the type need not
have the same bounds).]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I1864"></A><A NAME="I1865"></A>A <FONT FACE="Arial, Helvetica">constrained_array_definition</FONT>
defines an array type with a constrained first subtype. Each <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>
defines the corresponding index subtype, as well as the corresponding
index range for the constrained first subtype. <A NAME="I1866"></A>The
<I>constraint</I> of the first subtype consists of the bounds of the
index ranges. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>Although there
is no namable unconstrained array subtype in this case, the predefined
slicing and concatenation operations can operate on and yield values
that do not necessarily belong to the first array subtype. This is also
true for Ada 83. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;The discrete subtype
defined by a <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>
is either that defined by the <FONT FACE="Arial, Helvetica">subtype_indication</FONT>,
or a subtype determined by the <FONT FACE="Arial, Helvetica">range</FONT>
as follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>If the type of the <FONT FACE="Arial, Helvetica">range</FONT>
resolves to <I>root_integer</I>, then the <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>
defines a subtype of the predefined type Integer with bounds given by
a conversion to Integer of the bounds of the <FONT FACE="Arial, Helvetica">range</FONT>;
<A NAME="I1867"></A></LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>18.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This ensures that
indexing over the discrete subtype can be performed with regular Integers,
rather than only <I>universal_integer</I>s. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>We considered
doing this by simply creating a ``preference'' for Integer when resolving
the <FONT FACE="Arial, Helvetica">range</FONT>. <A NAME="I1868"></A>However,
this can introduce <I>Beaujolais</I> effects when the <FONT FACE="Arial, Helvetica">simple_expression</FONT>s
involve calls on functions visible due to <B>use</B> clauses. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>Otherwise, the <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>
defines a subtype of the type of the <FONT FACE="Arial, Helvetica">range</FONT>,
with the bounds given by the <FONT FACE="Arial, Helvetica">range</FONT>.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I1869"></A>The <FONT FACE="Arial, Helvetica">component_definition</FONT>
of an <FONT FACE="Arial, Helvetica">array_type_definition</FONT> defines
the nominal subtype of the components. If the reserved word <B>aliased</B>
appears in the <FONT FACE="Arial, Helvetica">component_definition</FONT>,
then each component of the array is aliased (see <A HREF="AA-3-10.html">3.10</A>).
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>In this case,
the nominal subtype cannot be an unconstrained discriminated subtype.
See <A HREF="AA-3-8.html">3.8</A>. </FONT></DIV>

<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I1870"></A>The elaboration of an <FONT FACE="Arial, Helvetica">array_type_definition</FONT>
creates the array type and its first subtype, and consists of the elaboration
of any <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>s
and the <FONT FACE="Arial, Helvetica">component_definition</FONT>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0002">8652/0002</A></I>}
<A NAME="I1871"></A>The elaboration of a <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>
<U>that does not contain any per-object expressions</U> creates the discrete
subtype, and consists of the elaboration of the <FONT FACE="Arial, Helvetica">subtype_indication</FONT>
or the evaluation of the <FONT FACE="Arial, Helvetica">range</FONT>.
<U>The elaboration of a <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>
that contains one or more per-object expressions is defined in <A HREF="AA-3-8.html">3.8</A>.</U>
<A NAME="I1872"></A>The elaboration of a <FONT FACE="Arial, Helvetica">component_definition</FONT>
in an <FONT FACE="Arial, Helvetica">array_type_definition</FONT> consists
of the elaboration of the <FONT FACE="Arial, Helvetica">subtype_indication</FONT>.
The elaboration of any <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>s
and the elaboration of the <FONT FACE="Arial, Helvetica">component_definition</FONT>
are performed in an arbitrary order. </DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>41&nbsp;&nbsp;All components of an array
have the same subtype. In particular, for an array of components that
are one-dimensional arrays, this means that all components have the same
bounds and hence the same length.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>42&nbsp;&nbsp;Each elaboration of an
<FONT FACE="Arial, Helvetica">array_type_definition</FONT> creates a
distinct array type. A consequence of this is that each object whose
<FONT FACE="Arial, Helvetica">object_declaration</FONT> contains an <FONT FACE="Arial, Helvetica">array_type_definition</FONT>
is of its own unique type. </FONT></DIV>

<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<I>Examples of
type declarations with unconstrained array definitions: </I></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B>&nbsp;Vector&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>is</B>&nbsp;<B>array</B>(Integer&nbsp;&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;<B>of</B>&nbsp;Real;<BR>
<B>type</B>&nbsp;Matrix&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>is</B>&nbsp;<B>array</B>(Integer&nbsp;&nbsp;<B>range</B>&nbsp;&lt;&gt;,&nbsp;Integer&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;<B>of</B>&nbsp;Real;<BR>
<B>type</B>&nbsp;Bit_Vector&nbsp;<B>is</B>&nbsp;<B>array</B>(Integer&nbsp;&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;<B>of</B>&nbsp;Boolean;<BR>
<B>type</B>&nbsp;Roman&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>is</B>&nbsp;<B>array</B>(Positive&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;<B>of</B>&nbsp;Roman_Digit;&nbsp;<I>--&nbsp;see&nbsp;<A HREF="AA-3-5-2.html">3.5.2</A></I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<I>Examples of type
declarations with constrained array definitions: </I></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B>&nbsp;Table&nbsp;&nbsp;&nbsp;&nbsp;<B>is</B>&nbsp;<B>array</B>(1&nbsp;..&nbsp;10)&nbsp;<B>of</B>&nbsp;Integer;<BR>
<B>type</B>&nbsp;Schedule&nbsp;<B>is</B>&nbsp;<B>array</B>(Day)&nbsp;<B>of</B>&nbsp;Boolean;<BR>
<B>type</B>&nbsp;Line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>is</B>&nbsp;<B>array</B>(1&nbsp;..&nbsp;Max_Line_Size)&nbsp;<B>of</B>&nbsp;Character;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<I>Examples of object
declarations with array type definitions: </I></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="Examples"><TT>Grid&nbsp;:&nbsp;<B>array</B>(1&nbsp;..&nbsp;80,&nbsp;1&nbsp;..&nbsp;100)&nbsp;<B>of</B>&nbsp;Boolean;<BR>
Mix&nbsp;&nbsp;:&nbsp;<B>array</B>(Color&nbsp;<B>range</B>&nbsp;Red&nbsp;..&nbsp;Green)&nbsp;<B>of</B>&nbsp;Boolean;<BR>
Page&nbsp;:&nbsp;<B>array</B>(Positive&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;<B>of</B>&nbsp;Line&nbsp;:=&nbsp;&nbsp;<I>--&nbsp;&nbsp;an&nbsp;array&nbsp;of&nbsp;arrays</I><BR>
&nbsp;&nbsp;(1&nbsp;|&nbsp;50&nbsp;&nbsp;=&gt;&nbsp;Line'(1&nbsp;|&nbsp;Line'Last&nbsp;=&gt;&nbsp;'+',&nbsp;others&nbsp;=&gt;&nbsp;'-'),&nbsp;&nbsp;<I>--&nbsp;see&nbsp;<A HREF="AA-4-3-3.html">4.3.3</A></I><BR>
&nbsp;&nbsp;&nbsp;2&nbsp;..&nbsp;49&nbsp;=&gt;&nbsp;Line'(1&nbsp;|&nbsp;Line'Last&nbsp;=&gt;&nbsp;'|',&nbsp;others&nbsp;=&gt;&nbsp;'&nbsp;'));<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I>--&nbsp;Page&nbsp;is&nbsp;constrained&nbsp;by&nbsp;its&nbsp;initial&nbsp;value&nbsp;to&nbsp;(1..50)</I></TT></DIV>

<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>30.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I1873"></A>The syntax
rule for <FONT FACE="Arial, Helvetica">component_definition</FONT> is
modified to allow the reserved word <B>aliased</B>.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The syntax rules for <FONT FACE="Arial, Helvetica">unconstrained_array_definition</FONT>
and <FONT FACE="Arial, Helvetica">constrained_array_definition</FONT>
are modified to use <FONT FACE="Arial, Helvetica">component_definition</FONT>
(instead of <I>component_</I><FONT FACE="Arial, Helvetica">subtype_indication</FONT>).
The effect of this change is to allow the reserved word <B>aliased</B>
before the component <FONT FACE="Arial, Helvetica">subtype_indication</FONT>.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>A <FONT FACE="Arial, Helvetica">range</FONT>
in a <FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>
may use arbitrary universal expressions for each bound (e.g. -1 .. 3+5),
rather than strictly &quot;implicitly convertible&quot; operands. The
subtype defined will still be a subtype of Integer. </FONT></DIV>

<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>30.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We introduce a new syntactic category,
<FONT FACE="Arial, Helvetica">discrete_subtype_definition</FONT>, as
distinct from <FONT FACE="Arial, Helvetica">discrete_range</FONT>. These
two constructs have the same syntax, but their semantics are quite different
(one defines a subtype, with a preference for Integer subtypes, while
the other just selects a subrange of an existing subtype). We use this
new syntactic category in <B>for</B> loops and entry families.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30.e</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The syntax for <FONT FACE="Arial, Helvetica">index_constraint</FONT>
and <FONT FACE="Arial, Helvetica">discrete_range</FONT> have been moved
to their own subclause, since they are no longer used here.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30.f</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The syntax rule for <FONT FACE="Arial, Helvetica">component_definition</FONT>
(formerly <FONT FACE="Arial, Helvetica">component_subtype_definition</FONT>)
is moved here from RM83-3.7. </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-3-5-10.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-3-6-1.html">Next</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>