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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Objects and Named Numbers</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-3-2-3.html">Previous</A> <A HREF="AA-3-3-1.html">Next</A></P>
<HR>
<H1> 3.3 Objects and Named Numbers</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [Objects are created at run time and contain a
value of a given type. <A NAME="I1427"></A>An object can be created and
initialized as part of elaborating a declaration, evaluating an <FONT FACE="Arial, Helvetica">allocator</FONT>,
<FONT FACE="Arial, Helvetica">aggregate</FONT>, or <FONT FACE="Arial, Helvetica">function_call</FONT>,
or passing a parameter by copy. Prior to reclaiming the storage for an
object, it is finalized if necessary (see <A HREF="AA-7-6-1.html">7.6.1</A>).]
</DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <A NAME="I1428"></A>All
of the following are objects: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Glossary entry: </B>An object
is either a constant or a variable. An object contains a value. An object
is created by an <FONT FACE="Arial, Helvetica">object_declaration</FONT>
or by an <FONT FACE="Arial, Helvetica">allocator</FONT>. A formal parameter
is (a view of) an object. A subcomponent of an object is an object.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the entity declared by an <FONT FACE="Arial, Helvetica">object_declaration</FONT>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a formal parameter of a subprogram, entry, or generic subprogram;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a generic formal object;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a loop parameter;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a choice parameter of an <FONT FACE="Arial, Helvetica">exception_handler</FONT>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>an entry index of an <FONT FACE="Arial, Helvetica">entry_body</FONT>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the result of dereferencing an access-to-object value (see
<A HREF="AA-4-1.html">4.1</A>);</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the result of evaluating a <FONT FACE="Arial, Helvetica">function_call</FONT>
(or the equivalent operator invocation -- see <A HREF="AA-6-6.html">6.6</A>);</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the result of evaluating an <FONT FACE="Arial, Helvetica">aggregate</FONT>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a component, slice, or view conversion of another object.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1429"></A><A NAME="I1430"></A><A NAME="I1431"></A><A NAME="I1432"></A><A NAME="I1433"></A><A NAME="I1434"></A>An
object is either a <I>constant</I> object or a <I>variable</I> object.
The value of a constant object cannot be changed between its initialization
and its finalization, whereas the value of a variable object can be changed.
Similarly, a view of an object is either a <I>constant</I> or a <I>variable</I>.
All views of a constant object are constant. A constant view of a variable
object cannot be used to modify the value of the variable. The terms
constant and variable by themselves refer to constant and variable views
of objects.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1435"></A>The value of an object is
<I>read</I> when the value of any part of the object is evaluated, or
when the value of an enclosing object is evaluated. <A NAME="I1436"></A>The
value of a variable is <I>updated</I> when an assignment is performed
to any part of the variable, or when an assignment is performed to an
enclosing object. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Reading and
updating are intended to include read/write references of any kind, even
if they are not associated with the evaluation of a particular construct.
Consider, for example, the expression ``X.<B>all</B>(F)'', where X is
an access-to-array object, and F is a function. The implementation is
allowed to first evaluate ``X.<B>all</B>'' and then F. Finally, a read
is performed to get the value of the F'th component of the array. Note
that the array is not necessarily read as part of the evaluation of ``X.<B>all</B>''.
This is important, because if F were to free X using Unchecked_Deallocation,
we want the execution of the final read to be erroneous. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> Whether a view
of an object is constant or variable is determined by the definition
of the view. The following (and no others) represent constants: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>an object declared by an <FONT FACE="Arial, Helvetica">object_declaration</FONT>
with the reserved word <B>constant</B>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a formal parameter or generic formal object of mode <B>in</B>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a discriminant;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a loop parameter, choice parameter, or entry index;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the dereference of an access-to-constant value;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the result of evaluating a <FONT FACE="Arial, Helvetica">function_call</FONT>
or an <FONT FACE="Arial, Helvetica">aggregate</FONT>;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a <FONT FACE="Arial, Helvetica">selected_component</FONT>,
<FONT FACE="Arial, Helvetica">indexed_component</FONT>, <FONT FACE="Arial, Helvetica">slice</FONT>,
or view conversion of a constant. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>22.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>A noninvertible
view conversion to a general access type is also defined to be a constant
-- see <A HREF="AA-4-6.html">4.6</A>. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1437"></A>At the place where a view
of an object is defined, a <I>nominal subtype</I> is associated with
the view. <A NAME="I1438"></A><A NAME="I1439"></A>The object's <I>actual
subtype</I> (that is, its subtype) can be more restrictive than the nominal
subtype of the view; it always is if the nominal subtype is an <I>indefinite
subtype</I>. <A NAME="I1440"></A><A NAME="I1441"></A>A subtype is an
indefinite subtype if it is an unconstrained array subtype, or if it
has unknown discriminants or unconstrained discriminants without defaults
(see <A HREF="AA-3-7.html">3.7</A>); otherwise the subtype is a <I>definite</I>
subtype [(all elementary subtypes are definite subtypes)]. [A class-wide
subtype is defined to have unknown discriminants, and is therefore an
indefinite subtype. An indefinite subtype does not by itself provide
enough information to create an object; an additional <FONT FACE="Arial, Helvetica">constraint</FONT>
or explicit initialization <FONT FACE="Arial, Helvetica">expression</FONT>
is necessary (see <A HREF="AA-3-3-1.html">3.3.1</A>). A component cannot
have an indefinite nominal subtype. ]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1442"></A>A <I>named number</I> provides
a name for a numeric value known at compile time. It is declared by a
<FONT FACE="Arial, Helvetica">number_declaration</FONT>. </DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>5 A constant cannot be the
target of an assignment operation, nor be passed as an <B>in</B> <B>out</B>
or <B>out</B> parameter, between its initialization and finalization,
if any.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>6 The nominal and actual
subtypes of an elementary object are always the same. For a discriminated
or array object, if the nominal subtype is constrained then so is the
actual subtype. </FONT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>26.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I1443"></A>There are
additional kinds of objects (choice parameters and entry indices of entry
bodies).</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The result of a function and of
evaluating an aggregate are considered (constant) objects. This is necessary
to explain the action of finalization on such things. Because a <FONT FACE="Arial, Helvetica">function_call</FONT>
is also syntactically a <FONT FACE="Arial, Helvetica">name</FONT> (see
<A HREF="AA-4-1.html">4.1</A>), the result of a <FONT FACE="Arial, Helvetica">function_call</FONT>
can be renamed, thereby allowing repeated use of the result without calling
the function again. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>26.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>This clause and its subclauses
now follow the clause and subclauses on types and subtypes, to cut down
on the number of forward references.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The term nominal subtype is new.
It is used to distinguish what is known at compile time about an object's
constraint, versus what its "true" run-time constraint is.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26.e</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The terms definite and indefinite
(which apply to subtypes) are new. They are used to aid in the description
of generic formal type matching, and to specify when an explicit initial
value is required in an <FONT FACE="Arial, Helvetica">object_declaration</FONT>.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26.f</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We have moved the syntax for <FONT FACE="Arial, Helvetica">object_declaration</FONT>
and <FONT FACE="Arial, Helvetica">number_declaration</FONT> down into
their respective subclauses, to keep the syntax close to the description
of the associated semantics.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26.g</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We talk about variables and constants
here, since the discussion is not specific to <FONT FACE="Arial, Helvetica">object_declaration</FONT>s,
and it seems better to have the list of the kinds of constants juxtaposed
with the kinds of objects.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26.h</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We no longer talk about indirect
updating due to parameter passing. Parameter passing is handled in 6.2
and 6.4.1 in a way that there is no need to mention it here in the definition
of read and update. Reading and updating now includes the case of evaluating
or assigning to an enclosing object. </FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-3-2-3.html">Previous</A> <A HREF="AA-3-3-1.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|