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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Declarative Parts</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-3-10-2.html">Previous</A> <A HREF="AA-3-11-1.html">Next</A></P>
<HR>
<H1> 3.11 Declarative Parts</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [A <FONT FACE="Arial, Helvetica">declarative_part</FONT>
contains <FONT FACE="Arial, Helvetica">declarative_item</FONT>s (possibly
none).] </DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">declarative_part<A NAME="I2220"></A>
::= </FONT>{<A NAME="I2221"></A><FONT FACE="Arial, Helvetica">declarative_item</FONT>}</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">declarative_item<A NAME="I2222"></A>
::= </FONT><BR>
<A NAME="I2223"></A><FONT FACE="Arial, Helvetica">basic_declarative_item</FONT> | <A NAME="I2224"></A><FONT FACE="Arial, Helvetica">body</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4/1</FONT></DIV>
<DIV Class="SyntaxIndented">{<I><A HREF="defect1.html#8652/0009">8652/0009</A></I>}
<FONT FACE="Arial, Helvetica">basic_declarative_item<A NAME="I2225"></A>
::= </FONT><BR>
<A NAME="I2226"></A><FONT FACE="Arial, Helvetica">basic_declaration</FONT> | <U><A NAME="I2227"></A><FONT FACE="Arial, Helvetica">aspect_clause</FONT></U><S><A NAME="I2228"></A><FONT FACE="Arial, Helvetica">representation_clause</FONT></S> | <A NAME="I2229"></A><FONT FACE="Arial, Helvetica">use_clause</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">body<A NAME="I2230"></A>
::= </FONT><A NAME="I2231"></A><FONT FACE="Arial, Helvetica">proper_body</FONT> | <A NAME="I2232"></A><FONT FACE="Arial, Helvetica">body_stub</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">proper_body<A NAME="I2233"></A>
::= </FONT><BR>
<A NAME="I2234"></A><FONT FACE="Arial, Helvetica">subprogram_body</FONT> | <A NAME="I2235"></A><FONT FACE="Arial, Helvetica">package_body</FONT> | <A NAME="I2236"></A><FONT FACE="Arial, Helvetica">task_body</FONT> | <A NAME="I2237"></A><FONT FACE="Arial, Helvetica">protected_body</FONT></DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2238"></A>The elaboration of a <FONT FACE="Arial, Helvetica">declarative_part</FONT>
consists of the elaboration of the <FONT FACE="Arial, Helvetica">declarative_item</FONT>s,
if any, in the order in which they are given in the <FONT FACE="Arial, Helvetica">declarative_part</FONT>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2239"></A>An elaborable construct is
in the <I>elaborated</I> state after the normal completion of its elaboration.
Prior to that, it is <I>not yet elaborated</I>. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The elaborated
state is only important for bodies; certain uses of a body raise an exception
if the body is not yet elaborated.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that "prior" implies
before the start of elaboration, as well as during elaboration.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The use of the term "normal
completion" implies that if the elaboration propagates an exception
or is aborted, the declaration is not elaborated. RM83 missed the aborted
case. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2240"></A><A NAME="I2241"></A>For a
construct that attempts to use a body, a check (Elaboration_Check) is
performed, as follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10/1</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>{<I><A HREF="defect1.html#8652/0014">8652/0014</A></I>}
For a call to a (non-protected) subprogram that has an explicit body,
a check is made that the <U>body</U><S><FONT FACE="Arial, Helvetica">subprogram_body</FONT></S>
is already elaborated. This check and the evaluations of any actual parameters
of the call are done in an arbitrary order. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>10.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>AI83-00180
specifies that there is no elaboration check for a subprogram defined
by a <FONT FACE="Arial, Helvetica">pragma</FONT> Interface (or equivalently,
<FONT FACE="Arial, Helvetica">pragma</FONT> Import). AI83-00430 specifies
that there is no elaboration check for an enumeration literal. AI83-00406
specifies that the evaluation of parameters and the elaboration check
occur in an arbitrary order. AI83-00406 applies to generic instantiation
as well (see below).</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10.a.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>{<I><A HREF="defect1.html#8652/0014">8652/0014</A></I>}
<U>A subprogram can be completed by a renames-as-body, and we need to
make an elaboration check on such a body, so we use ``body'' rather than
<FONT FACE="Arial, Helvetica">subprogram_body</FONT> above.</U> </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For a call to a protected operation of a protected type
(that has a body -- no check is performed if a <FONT FACE="Arial, Helvetica">pragma</FONT>
Import applies to the protected type), a check is made that the <FONT FACE="Arial, Helvetica">protected_body</FONT>
is already elaborated. This check and the evaluations of any actual parameters
of the call are done in an arbitrary order. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>A protected
type has only one elaboration ``bit,'' rather than one for each operation,
because one call may result in evaluating the barriers of other entries,
and because there are no elaborable declarations between the bodies of
the operations. In fact, the elaboration of a <FONT FACE="Arial, Helvetica">protected_body</FONT>
does not elaborate the enclosed bodies, since they are not considered
independently elaborable.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that there is no elaboration
check when calling a task entry. Task entry calls are permitted even
before the associated <FONT FACE="Arial, Helvetica">task_body</FONT>
has been seen. Such calls are simply queued until the task is activated
and reaches a corresponding <FONT FACE="Arial, Helvetica">accept_statement</FONT>.
We considered a similar rule for protected entries -- simply queuing
all calls until the <FONT FACE="Arial, Helvetica">protected_body</FONT>
was seen, but felt it was not worth the possible implementation overhead,
particularly given that there might be multiple instances of the protected
type. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For the activation of a task, a check is made by the activator
that the <FONT FACE="Arial, Helvetica">task_body</FONT> is already elaborated.
If two or more tasks are being activated together (see <A HREF="AA-9-2.html">9.2</A>),
as the result of the elaboration of a <FONT FACE="Arial, Helvetica">declarative_part</FONT>
or the initialization for the object created by an allocator, this check
is done for all of them before activating any of them. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>As specified by
AI83-00149, the check is done by the activator, rather than by the task
itself. If it were done by the task itself, it would be turned into a
Tasking_Error in the activator, and the other tasks would still be activated.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>For the instantiation of a generic unit that has a body,
a check is made that this body is already elaborated. This check and
the evaluation of any <FONT FACE="Arial, Helvetica">explicit_generic_actual_parameter</FONT>s
of the instantiation are done in an arbitrary order. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2242"></A>The exception Program_Error
is raised if any of these checks fails. </DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>14.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I2243"></A>The syntax
for <FONT FACE="Arial, Helvetica">declarative_part</FONT> is modified
to remove the ordering restrictions of Ada 83; that is, the distinction
between <FONT FACE="Arial, Helvetica">basic_declarative_item</FONT>s
and <FONT FACE="Arial, Helvetica">later_declarative_item</FONT>s within
<FONT FACE="Arial, Helvetica">declarative_part</FONT>s is removed. This
means that things like <FONT FACE="Arial, Helvetica">use_clause</FONT>s
and <FONT FACE="Arial, Helvetica">variable_declaration</FONT>s can be
freely intermixed with things like bodies.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The syntax rule for <FONT FACE="Arial, Helvetica">proper_body</FONT>
now allows a <FONT FACE="Arial, Helvetica">protected_body</FONT>, and
the rules for elaboration checks now cover calls on protected operations.
</FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>14.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The syntax rule for <FONT FACE="Arial, Helvetica">later_declarative_item</FONT>
is removed; the syntax rule for <FONT FACE="Arial, Helvetica">declarative_item</FONT>
is new.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>RM83 defines ``elaborated'' and
``not yet elaborated'' for <FONT FACE="Arial, Helvetica">declarative_item</FONT>s
here, and for other things in <A HREF="AA-3-1.html">3.1</A>, ``<A HREF="AA-3-1.html">Declarations</A>''.
That's no longer necessary, since these terms are fully defined in <A HREF="AA-3-1.html">3.1</A>.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14.e</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>In RM83, all uses of <FONT FACE="Arial, Helvetica">declarative_part</FONT>
are optional (except for the one in <FONT FACE="Arial, Helvetica">block_statement</FONT>
with a <B>declare</B>) which is sort of strange, since a <FONT FACE="Arial, Helvetica">declarative_part</FONT>
can be empty, according to the syntax. That is, <FONT FACE="Arial, Helvetica">declarative_part</FONT>s
are sort of ``doubly optional''. In Ada 95, these <FONT FACE="Arial, Helvetica">declarative_part</FONT>s
are always required (but can still be empty). To simplify description,
we go further and say (see <A HREF="AA-5-6.html">5.6</A>, ``<A HREF="AA-5-6.html">Block
Statements</A>'') that a <FONT FACE="Arial, Helvetica">block_statement</FONT>
without an explicit <FONT FACE="Arial, Helvetica">declarative_part</FONT>
is equivalent to one with an empty one. </FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-3-10-2.html">Previous</A> <A HREF="AA-3-11-1.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|