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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Completions of 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> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-3-11.html">Previous</A> <A HREF="AA-4.html">Next</A></P>
<HR>
<H1> 3.11.1 Completions of Declarations</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1/1</FONT></DIV>
<DIV Class="Normal"> {<I><A HREF="defect1.html#8652/0014">8652/0014</A></I>}
Declarations sometimes come in two parts. <A NAME="I2244"></A>A declaration
that requires a second part is said to <I>require completion</I>. <A NAME="I2245"></A>The
second part is called the <I>completion</I> of the declaration (and of
the entity declared), and is either another declaration, a body, or a
<FONT FACE="Arial, Helvetica">pragma</FONT>. <U>A <A NAME="I2246"></A><I>body</I>
is a <FONT FACE="Arial, Helvetica">body</FONT>, an <FONT FACE="Arial, Helvetica">entry_body</FONT>,
or a renaming-as-body (see <A HREF="AA-8-5-4.html">8.5.4</A>).</U> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>1.a</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1><B>Discussion:
</B>Throughout the RM95, there are rules about completions that define
the following: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>1.b</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>Which declarations require a corresponding completion.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>1.c</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>Which constructs can only serve as the completion of a
declaration.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>1.d</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>Where the completion of a declaration is allowed to be.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>1.e</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>What kinds of completions are allowed to correspond to
each kind of declaration that allows one. </LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>1.f</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Don't confuse this compile-time
concept with the run-time concept of completion defined in <A HREF="AA-7-6-1.html">7.6.1</A>.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>1.g</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that the declaration of a
private type (if limited) can be completed with the declaration of a
task type, which is then completed with a body. Thus, a declaration can
actually come in <I>three</I> parts. </FONT></DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> A construct that
can be a completion is interpreted as the completion of a prior declaration
only if: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The declaration and the completion occur immediately within
the same declarative region;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The defining name or <FONT FACE="Arial, Helvetica">defining_program_unit_name</FONT>
in the completion is the same as in the declaration, or in the case of
a <FONT FACE="Arial, Helvetica">pragma</FONT>, the <FONT FACE="Arial, Helvetica">pragma</FONT>
applies to the declaration;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>If the declaration is overloadable, then the completion
either has a type-conformant profile, or is a <FONT FACE="Arial, Helvetica">pragma</FONT>.
<A NAME="I2247"></A></LI></UL>
<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal"> An implicit declaration shall not have a completion.
<A NAME="I2248"></A>For any explicit declaration that is specified to
<I>require completion</I>, there shall be a corresponding explicit completion.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>The implicit
declarations of predefined operators are not allowed to have a completion.
Enumeration literals, although they are subprograms, are not allowed
to have a corresponding <FONT FACE="Arial, Helvetica">subprogram_body</FONT>.
That's because the completion rules are described in terms of constructs
(<FONT FACE="Arial, Helvetica">subprogram_declaration</FONT>s) and not
entities (subprograms). When a completion is required, it has to be explicit;
the implicit null <FONT FACE="Arial, Helvetica">package_body</FONT> that
Section 7 talks about cannot serve as the completion of a <FONT FACE="Arial, Helvetica">package_declaration</FONT>
if a completion is required. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> At most one completion is allowed for a given
declaration. Additional requirements on completions appear where each
kind of completion is defined. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>A subunit
is not a completion; the stub is.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>If the completion of a declaration
is also a declaration, then <I>that</I> declaration might have a completion,
too. For example, a limited private type can be completed with a task
type, which can then be completed with a task body. This is not a violation
of the ``at most one completion'' rule. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2249"></A>A type is <I>completely defined</I>
at a place that is after its full type definition (if it has one) and
after all of its subcomponent types are completely defined. A type shall
be completely defined before it is frozen (see <A HREF="AA-13-14.html">13.14</A>
and <A HREF="AA-7-3.html">7.3</A>). </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>Index types are
always completely defined -- no need to mention them. There is no way
for a completely defined type to depend on the value of a (still) deferred
constant. </FONT></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>88 Completions are in principle
allowed for any kind of explicit declaration. However, for some kinds
of declaration, the only allowed completion is a <FONT FACE="Arial, Helvetica">pragma</FONT>
Import, and implementations are not required to support <FONT FACE="Arial, Helvetica">pragma</FONT>
Import for every kind of entity. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>In fact, we
expect that implementations will <I>not</I> support pragma Import of
things like types -- it's hard to even define the semantics of what it
would mean. Therefore, in practice, <I>not</I> every explicit declaration
can have a completion. In any case, if an implementation chooses to support
pragma Import for, say, types, it can place whatever restrictions on
the feature it wants to. For example, it might want the <FONT FACE="Arial, Helvetica">pragma</FONT>
to be a freezing point for the type. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>89 There are rules that prevent
premature uses of declarations that have a corresponding completion.
The Elaboration_Checks of <A HREF="AA-3-11.html">3.11</A> prevent such
uses at run time for subprograms, protected operations, tasks, and generic
units. The rules of <A HREF="AA-13-14.html">13.14</A>, ``<A HREF="AA-13-14.html">Freezing
Rules</A>'' prevent, at compile time, premature uses of other entities
such as private types and deferred constants. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>10.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>This subclause is new. It is intended
to cover all kinds of completions of declarations, be they a body for
a spec, a full type for an incomplete or private type, a full constant
declaration for a deferred constant declaration, or a <FONT FACE="Arial, Helvetica">pragma</FONT>
Import for any kind of entity. </FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-3-11.html">Previous</A> <A HREF="AA-4.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|