File: AA-3-3-1.html

package info (click to toggle)
ada-reference-manual 20021112web-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 18,652 kB
  • ctags: 8,921
  • sloc: makefile: 52; sh: 20
file content (377 lines) | stat: -rw-r--r-- 28,601 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>AARM95 - Object 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>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-3-3.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-3-3-2.html">Next</A></P>
<HR>
<H1> 3.3.1 Object Declarations</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I1444"></A><A NAME="I1445"></A><A NAME="I1446"></A>An
<FONT FACE="Arial, Helvetica">object_declaration</FONT> declares a <I>stand-alone</I>
object with a given nominal subtype and, optionally, an explicit initial
value given by an initialization expression. <A NAME="I1447"></A><A NAME="I1448"></A><A NAME="I1449"></A>For
an array, task, or protected object, the <FONT FACE="Arial, Helvetica">object_declaration</FONT>
may include the definition of the (anonymous) type of the object. </DIV>

<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">object_declaration<A NAME="I1450"></A>
::= </FONT><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I1451"></A><FONT FACE="Arial, Helvetica">defining_identifier_list</FONT>&nbsp;:&nbsp;[<B>aliased</B>]&nbsp;[<B>constant</B>]&nbsp;<A NAME="I1452"></A><FONT FACE="Arial, Helvetica">subtype_indication</FONT>&nbsp;[:=&nbsp;<A NAME="I1453"></A><FONT FACE="Arial, Helvetica">expression</FONT>];<BR>
&nbsp;&nbsp;|&nbsp;<A NAME="I1454"></A><FONT FACE="Arial, Helvetica">defining_identifier_list</FONT>&nbsp;:&nbsp;[<B>aliased</B>]&nbsp;[<B>constant</B>]&nbsp;<A NAME="I1455"></A><FONT FACE="Arial, Helvetica">array_type_definition</FONT>&nbsp;[:=&nbsp;<A NAME="I1456"></A><FONT FACE="Arial, Helvetica">expression</FONT>];<BR>
&nbsp;&nbsp;|&nbsp;<A NAME="I1457"></A><FONT FACE="Arial, Helvetica">single_task_declaration</FONT><BR>
&nbsp;&nbsp;|&nbsp;<A NAME="I1458"></A><FONT FACE="Arial, Helvetica">single_protected_declaration</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">defining_identifier_list<A NAME="I1459"></A>
::= </FONT><BR>
&nbsp;&nbsp;<A NAME="I1460"></A><FONT FACE="Arial, Helvetica">defining_identifier</FONT>&nbsp;{,&nbsp;<A NAME="I1461"></A><FONT FACE="Arial, Helvetica">defining_identifier</FONT>}</DIV>

<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I1462"></A>For an <FONT FACE="Arial, Helvetica">object_declaration</FONT>
with an <FONT FACE="Arial, Helvetica">expression</FONT> following the
compound delimiter :=, the type expected for the <FONT FACE="Arial, Helvetica">expression</FONT>
is that of the object. <A NAME="I1463"></A>This <FONT FACE="Arial, Helvetica">expression</FONT>
is called the <I>initialization expression</I>. <A NAME="I1464"></A></DIV>

<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;An <FONT FACE="Arial, Helvetica">object_declaration</FONT>
without the reserved word <B>constant</B> declares a variable object.
If it has a <FONT FACE="Arial, Helvetica">subtype_indication</FONT> or
an <FONT FACE="Arial, Helvetica">array_type_definition</FONT> that defines
an indefinite subtype, then there shall be an initialization expression.
An initialization expression shall not be given if the object is of a
limited type. </DIV>

<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;An <FONT FACE="Arial, Helvetica">object_declaration</FONT>
with the reserved word <B>constant</B> declares a constant object. <A NAME="I1465"></A>If
it has an initialization expression, then it is called a <I>full constant
declaration</I>. <A NAME="I1466"></A>Otherwise it is called a <I>deferred
constant declaration</I>. The rules for deferred constant declarations
are given in clause <A HREF="AA-7-4.html">7.4</A>. The rules for full
constant declarations are given in this subclause.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;Any declaration that includes a <FONT FACE="Arial, Helvetica">defining_identifier_list</FONT>
with more than one <FONT FACE="Arial, Helvetica">defining_identifier</FONT>
is equivalent to a series of declarations each containing one <FONT FACE="Arial, Helvetica">defining_identifier</FONT>
from the list, with the rest of the text of the declaration copied for
each declaration in the series, in the same order as the list. The remainder
of this International Standard relies on this equivalence; explanations
are given for declarations with a single <FONT FACE="Arial, Helvetica">defining_identifier</FONT>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I1467"></A>The <FONT FACE="Arial, Helvetica">subtype_indication</FONT>
or full type definition of an <FONT FACE="Arial, Helvetica">object_declaration</FONT>
defines the nominal subtype of the object. The <FONT FACE="Arial, Helvetica">object_declaration</FONT>
declares an object of the type of the nominal subtype. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>The phrase
``full type definition'' here includes the case of an anonymous array,
task, or protected type. </FONT></DIV>

<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I1468"></A>If a composite object declared
by an <FONT FACE="Arial, Helvetica">object_declaration</FONT> has an
unconstrained nominal subtype, then if this subtype is indefinite or
the object is constant or aliased (see <A HREF="AA-3-10.html">3.10</A>)
the actual subtype of this object is constrained. The constraint is determined
by the bounds or discriminants (if any) of its initial value; <A NAME="I1469"></A>the
object is said to be <I>constrained by its initial value</I>. <A NAME="I1470"></A><A NAME="I1471"></A>[In
the case of an aliased object, this initial value may be either explicit
or implicit; in the other cases, an explicit initial value is required.]
When not constrained by its initial value, the actual and nominal subtypes
of the object are the same. <A NAME="I1472"></A><A NAME="I1473"></A>If
its actual subtype is constrained, the object is called a <I>constrained
object</I>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I1474"></A>For
an <FONT FACE="Arial, Helvetica">object_declaration</FONT> without an
initialization expression, any initial values for the object or its subcomponents
are determined by the <I>implicit initial values</I> defined for its
nominal subtype, as follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The implicit initial value for an access subtype is the
null value of the access type.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The implicit initial (and only) value for each discriminant
of a constrained discriminated subtype is defined by the subtype.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For a (definite) composite subtype, the implicit initial
value of each component with a <FONT FACE="Arial, Helvetica">default_expression</FONT>
is obtained by evaluation of this expression and conversion to the component's
nominal subtype (which might raise Constraint_Error -- see <A HREF="AA-4-6.html">4.6</A>,
``<A HREF="AA-4-6.html">Type Conversions</A>''), unless the component
is a discriminant of a constrained subtype (the previous case), or is
in an excluded <FONT FACE="Arial, Helvetica">variant</FONT> (see <A HREF="AA-3-8-1.html">3.8.1</A>).
<A NAME="I1475"></A>For each component that does not have a <FONT FACE="Arial, Helvetica">default_expression</FONT>,
any implicit initial values are those determined by the component's nominal
subtype.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For a protected or task subtype, there is an implicit component
(an entry queue) corresponding to each entry, with its implicit initial
value being an empty queue. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>14.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>The
implementation may add implicit components for its own use, which might
have implicit initial values. For a task subtype, such components might
represent the state of the associated thread of control. For a type with
dynamic-sized components, such implicit components might be used to hold
the offset to some explicit component. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I1476"></A>The
elaboration of an <FONT FACE="Arial, Helvetica">object_declaration</FONT>
proceeds in the following sequence of steps: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DL Class="Enumerated"><DT>&nbsp;&nbsp;&nbsp;&nbsp;1.<DD Class="Enumerated">
The <FONT FACE="Arial, Helvetica">subtype_indication</FONT>, <FONT FACE="Arial, Helvetica">array_type_definition</FONT>,
<FONT FACE="Arial, Helvetica">single_task_declaration</FONT>, or <FONT FACE="Arial, Helvetica">single_protected_declaration</FONT>
is first elaborated. This creates the nominal subtype (and the anonymous
type in the latter three cases).</DL>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DL Class="Enumerated"><DT>&nbsp;&nbsp;&nbsp;&nbsp;2.<DD Class="Enumerated">
If the <FONT FACE="Arial, Helvetica">object_declaration</FONT> includes
an initialization expression, the (explicit) initial value is obtained
by evaluating the expression and converting it to the nominal subtype
(which might raise Constraint_Error -- see <A HREF="AA-4-6.html">4.6</A>).
<A NAME="I1477"></A></DL>
<DIV Class="Paranum"><FONT SIZE=-2>18/1</FONT></DIV>
<DL Class="Enumerated"><DT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.<DD Class="Enumerated">
{<I><A HREF="defect1.html#8652/0002">8652/0002</A></I>} The object is
created, and, if there is not an initialization expression, any per-object
expressions (see <A HREF="AA-3-8.html">3.8</A>) are <U>elaborated</U><S>evaluated</S>
and any implicit initial values for the object or for its subcomponents
are obtained as determined by the nominal subtype. </DL>
<DIV Class="Paranum"><FONT SIZE=-2>18.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>For a per-object
constraint that contains some per-object expressions and some non-per-object
expressions, the values used for the constraint consist of the values
of the non-per-object expressions evaluated at the point of the <FONT FACE="Arial, Helvetica">type_declaration</FONT>,
and the values of the per-object expressions evaluated at the point of
the creation of the object.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The elaboration of per-object
constraints was presumably performed as part of the dependent compatibility
check in Ada 83. If the object is of a limited type with an access discriminant,
the <FONT FACE="Arial, Helvetica">access_definition</FONT> is elaborated
at this time (see <A HREF="AA-3-7.html">3.7</A>). </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The reason we say
that evaluating an explicit initialization expression happens before
creating the object is that in some cases it is impossible to know the
size of the object being created until its initial value is known, as
in ``X: String := Func_Call(...);''. The implementation can create the
object early in the common case where the size can be known early, since
this optimization is semantically neutral. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DL Class="Enumerated"><DT>&nbsp;&nbsp;&nbsp;&nbsp;4.<DD Class="Enumerated">
<A NAME="I1478"></A><A NAME="I1479"></A>Any initial values (whether explicit
or implicit) are assigned to the object or to the corresponding subcomponents.
As described in <A HREF="AA-5-2.html">5.2</A> and <A HREF="AA-7-6.html">7.6</A>,
Initialize and Adjust procedures can be called. <A NAME="I1480"></A></DL>
<DIV Class="Paranum"><FONT SIZE=-2>19.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Since the
initial values have already been converted to the appropriate nominal
subtype, the only Constraint_Errors that might occur as part of these
assignments are for values outside their base range that are used to
initialize unconstrained numeric subcomponents. See <A HREF="AA-3-5.html">3.5</A>.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;For the third step above, the object creation
and any elaborations and evaluations are performed in an arbitrary order,
except that if the <FONT FACE="Arial, Helvetica">default_expression</FONT>
for a discriminant is evaluated to obtain its initial value, then this
evaluation is performed before that of the <FONT FACE="Arial, Helvetica">default_expression</FONT>
for any component that depends on the discriminant, and also before that
of any <FONT FACE="Arial, Helvetica">default_expression</FONT> that includes
the name of the discriminant. The evaluations of the third step and the
assignments of the fourth step are performed in an arbitrary order, except
that each evaluation is performed before the resulting value is assigned.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.a</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1><B>Reason:
</B>For example: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.b</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>type</B>&nbsp;R(D&nbsp;:&nbsp;Integer&nbsp;:=&nbsp;F)&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>record</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S&nbsp;:&nbsp;String(1..D)&nbsp;:=&nbsp;(<B>others</B>&nbsp;=&gt;&nbsp;G);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;<B>record</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.c</FONT></DIV>
<DIV Class="SmallExamples"><TT>X&nbsp;:&nbsp;R;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>For the elaboration of the declaration
of X, it is important that F be evaluated before the aggregate. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;[There is no implicit initial value defined for
a scalar subtype.] <A NAME="I1481"></A>In the absence of an explicit
initialization, a newly created scalar object might have a value that
does not belong to its subtype (see <A HREF="AA-13-9-1.html">13.9.1</A>
and <A HREF="AA-H-1.html">H.1</A>). </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>It could
even be represented by a bit pattern that doesn't actually represent
any value of the type at all, such as an invalid internal code for an
enumeration type, or a NaN for a floating point type. It is a generally
a bounded error to reference scalar objects with such ``invalid representations'',
as explained in <A HREF="AA-13-9-1.html">13.9.1</A>, ``<A HREF="AA-13-9-1.html">Data
Validity</A>''. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>There is
no requirement that two objects of the same scalar subtype have the same
implicit initial ``value'' (or representation). It might even be the
case that two elaborations of the same <FONT FACE="Arial, Helvetica">object_declaration</FONT>
produce two different initial values. However, any particular uninitialized
object is default-initialized to a single value (or invalid representation).
Thus, multiple reads of such an uninitialized object will produce the
same value each time (if the implementation chooses not to detect the
error). </FONT></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>7&nbsp;&nbsp;Implicit initial values
are not defined for an indefinite subtype, because if an object's nominal
subtype is indefinite, an explicit initial value is required.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>8&nbsp;&nbsp;<A NAME="I1482"></A><A NAME="I1483"></A>As
indicated above, a stand-alone object is an object declared by an <FONT FACE="Arial, Helvetica">object_declaration</FONT>.
Similar definitions apply to ``stand-alone constant'' and ``stand-alone
variable.'' A subcomponent of an object is not a stand-alone object,
nor is an object that is created by an <FONT FACE="Arial, Helvetica">allocator</FONT>.
An object declared by a <FONT FACE="Arial, Helvetica">loop_parameter_specification</FONT>,
<FONT FACE="Arial, Helvetica">parameter_specification</FONT>, <FONT FACE="Arial, Helvetica">entry_index_specification</FONT>,
<FONT FACE="Arial, Helvetica">choice_parameter_specification</FONT>,
or a <FONT FACE="Arial, Helvetica">formal_object_declaration</FONT> is
not called a stand-alone object.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>9&nbsp;&nbsp;The type of a stand-alone
object cannot be abstract (see <A HREF="AA-3-9-3.html">3.9.3</A>). </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>Example of a
multiple object declaration:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Examples"><TT><I>--&nbsp;&nbsp;the&nbsp;multiple&nbsp;object&nbsp;declaration&nbsp;</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Examples"><TT>John,&nbsp;Paul&nbsp;:&nbsp;Person_Name&nbsp;:=&nbsp;<B>new</B>&nbsp;Person(Sex&nbsp;=&gt;&nbsp;M);&nbsp;&nbsp;<I>--&nbsp;&nbsp;see&nbsp;<A HREF="AA-3-10-1.html">3.10.1</A></I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Examples"><TT><I>--&nbsp;&nbsp;is&nbsp;equivalent&nbsp;to&nbsp;the&nbsp;two&nbsp;single&nbsp;object&nbsp;declarations&nbsp;in&nbsp;the&nbsp;order&nbsp;given</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Examples"><TT>John&nbsp;:&nbsp;Person_Name&nbsp;:=&nbsp;<B>new</B>&nbsp;Person(Sex&nbsp;=&gt;&nbsp;M);<BR>
Paul&nbsp;:&nbsp;Person_Name&nbsp;:=&nbsp;<B>new</B>&nbsp;Person(Sex&nbsp;=&gt;&nbsp;M);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<I>Examples of variable
declarations:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<DIV Class="Examples"><TT>Count,&nbsp;Sum&nbsp;&nbsp;:&nbsp;Integer;<BR>
Size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;Integer&nbsp;<B>range</B>&nbsp;0&nbsp;..&nbsp;10_000&nbsp;:=&nbsp;0;<BR>
Sorted&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;Boolean&nbsp;:=&nbsp;False;<BR>
Color_Table&nbsp;:&nbsp;<B>array</B>(1&nbsp;..&nbsp;Max)&nbsp;<B>of</B>&nbsp;Color;<BR>
Option&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;Bit_Vector(1&nbsp;..&nbsp;10)&nbsp;:=&nbsp;(<B>others</B>&nbsp;=&gt;&nbsp;True);<BR>
Hello&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>constant</B>&nbsp;String&nbsp;:=&nbsp;&quot;Hi,&nbsp;world.&quot;;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<I>Examples of constant
declarations:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<DIV Class="Examples"><TT>Limit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>constant</B>&nbsp;Integer&nbsp;:=&nbsp;10_000;<BR>
Low_Limit&nbsp;:&nbsp;<B>constant</B>&nbsp;Integer&nbsp;:=&nbsp;Limit/10;<BR>
Tolerance&nbsp;:&nbsp;<B>constant</B>&nbsp;Real&nbsp;:=&nbsp;Dispersion(1.15);</TT></DIV>

<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>33.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I1484"></A>The syntax
rule for <FONT FACE="Arial, Helvetica">object_declaration</FONT> is modified
to allow the <B>aliased</B> reserved word.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>A variable declared by an <FONT FACE="Arial, Helvetica">object_declaration</FONT>
can be constrained by its initial value; that is, a variable of a nominally
unconstrained array subtype, or discriminated type without defaults,
can be declared so long as it has an explicit initial value. In Ada 83,
this was permitted for constants, and for variables created by allocators,
but not for variables declared by <FONT FACE="Arial, Helvetica">object_declaration</FONT>s.
This is particularly important for tagged class-wide types, since there
is no way to constrain them explicitly, and so an initial value is the
only way to provide a constraint. It is also important for generic formal
private types with unknown discriminants.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We now allow an <FONT FACE="Arial, Helvetica">unconstrained_array_definition</FONT>
in an <FONT FACE="Arial, Helvetica">object_declaration</FONT>. This allows
an object of an anonymous array type to have its bounds determined by
its initial value. This is for uniformity: If one can write ``X: <B>constant</B>
<B>array</B>(Integer <B>range</B> 1..10) <B>of</B> Integer := ...;''
then it makes sense to also allow ``X: <B>constant</B> <B>array</B>(Integer
<B>range</B> &lt;&gt;) <B>of</B> Integer := ...;''. (Note that if anonymous
array types are ever sensible, a common situation is for a table implemented
as an array. Tables are often constant, and for constants, there's usually
no point in forcing the user to count the number of elements in the value.)
</FONT></DIV>

<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>33.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We have moved the syntax for <FONT FACE="Arial, Helvetica">object_declaration</FONT>s
into this subclause.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33.e</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Deferred constants no longer have
a separate syntax rule, but rather are incorporated in <FONT FACE="Arial, Helvetica">object_declaration</FONT>
as constants declared without an initialization expression. </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-3.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-3-3-2.html">Next</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>