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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Ada95 - 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="RM-TOC.html">Contents</A> <A HREF="RM-0-29.html">Index</A> <A HREF="RM-3.html">Previous</A> <A HREF="RM-3-2.html">Next</A></P>
<HR>
<H1> 3.1 Declarations</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1260"></A>The language defines several
kinds of named <I>entities</I> that are declared by declarations. <A NAME="I1261"></A>The
entity's <I>name</I> is defined by the declaration, usually by a <FONT FACE="Arial, Helvetica">defining_identifier</FONT>,
but sometimes by a <FONT FACE="Arial, Helvetica">defining_character_literal</FONT>
or <FONT FACE="Arial, Helvetica">defining_operator_symbol</FONT>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal"> There are several forms of declaration. A <FONT FACE="Arial, Helvetica">basic_declaration</FONT>
is a form of declaration defined as follows. </DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">basic_declaration<A NAME="I1262"></A>
::= </FONT><BR>
<A NAME="I1263"></A><FONT FACE="Arial, Helvetica">type_declaration</FONT> | <A NAME="I1264"></A><FONT FACE="Arial, Helvetica">subtype_declaration</FONT><BR>
| <A NAME="I1265"></A><FONT FACE="Arial, Helvetica">object_declaration</FONT> | <A NAME="I1266"></A><FONT FACE="Arial, Helvetica">number_declaration</FONT><BR>
| <A NAME="I1267"></A><FONT FACE="Arial, Helvetica">subprogram_declaration</FONT> | <A NAME="I1268"></A><FONT FACE="Arial, Helvetica">abstract_subprogram_declaration</FONT><BR>
| <A NAME="I1269"></A><FONT FACE="Arial, Helvetica">package_declaration</FONT> | <A NAME="I1270"></A><FONT FACE="Arial, Helvetica">renaming_declaration</FONT><BR>
| <A NAME="I1271"></A><FONT FACE="Arial, Helvetica">exception_declaration</FONT> | <A NAME="I1272"></A><FONT FACE="Arial, Helvetica">generic_declaration</FONT><BR>
| <A NAME="I1273"></A><FONT FACE="Arial, Helvetica">generic_instantiation</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">defining_identifier<A NAME="I1274"></A>
::= </FONT><A NAME="I1275"></A><FONT FACE="Arial, Helvetica">identifier</FONT></DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1276"></A>A <I>declaration</I> is a
language construct that associates a name with (a view of) an entity.
<A NAME="I1277"></A><A NAME="I1278"></A>A declaration may appear explicitly
in the program text (an <I>explicit</I> declaration), or may be supposed
to occur at a given place in the text as a consequence of the semantics
of another construct (an <I>implicit</I> declaration). </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1279"></A>Each of the following is defined
to be a declaration: any <FONT FACE="Arial, Helvetica">basic_declaration</FONT>;
an <FONT FACE="Arial, Helvetica">enumeration_literal_specification</FONT>;
a <FONT FACE="Arial, Helvetica">discriminant_specification</FONT>; a
<FONT FACE="Arial, Helvetica">component_declaration</FONT>; a <FONT FACE="Arial, Helvetica">loop_parameter_specification</FONT>;
a <FONT FACE="Arial, Helvetica">parameter_specification</FONT>; a <FONT FACE="Arial, Helvetica">subprogram_body</FONT>;
an <FONT FACE="Arial, Helvetica">entry_declaration</FONT>; an <FONT FACE="Arial, Helvetica">entry_index_specification</FONT>;
a <FONT FACE="Arial, Helvetica">choice_parameter_specification</FONT>;
a <FONT FACE="Arial, Helvetica">generic_formal_parameter_declaration</FONT>.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1280"></A><A NAME="I1281"></A>All declarations
contain a <I>definition</I> for a <I>view</I> of an entity. A view consists
of an identification of the entity (the entity <I>of</I> the view), plus
view-specific characteristics that affect the use of the entity through
that view (such as mode of access to an object, formal parameter names
and defaults for a subprogram, or visibility to components of a type).
In most cases, a declaration also contains the definition for the entity
itself (a <FONT FACE="Arial, Helvetica">renaming_declaration</FONT> is
an example of a declaration that does not define a new entity, but instead
defines a view of an existing entity (see <A HREF="RM-8-5.html">8.5</A>)).
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1282"></A>For each declaration, the
language rules define a certain region of text called the <I>scope</I>
of the declaration (see <A HREF="RM-8-2.html">8.2</A>). Most declarations
associate an <FONT FACE="Arial, Helvetica">identifier</FONT> with a declared
entity. Within its scope, and only there, there are places where it is
possible to use the <FONT FACE="Arial, Helvetica">identifier</FONT> to
refer to the declaration, the view it defines, and the associated entity;
these places are defined by the visibility rules (see <A HREF="RM-8-3.html">8.3</A>).
<A NAME="I1283"></A>At such places the <FONT FACE="Arial, Helvetica">identifier</FONT>
is said to be a <I>name</I> of the entity (the <FONT FACE="Arial, Helvetica">direct_name</FONT>
or <FONT FACE="Arial, Helvetica">selector_name</FONT>); <A NAME="I1284"></A>the
name is said to <I>denote</I> the declaration, the view, and the associated
entity (see <A HREF="RM-8-6.html">8.6</A>). <A NAME="I1285"></A>The declaration
is said to <I>declare</I> the name, the view, and in most cases, the
entity itself.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal"> As an alternative to an <FONT FACE="Arial, Helvetica">identifier</FONT>,
an enumeration literal can be declared with a <FONT FACE="Arial, Helvetica">character_literal</FONT>
as its name (see <A HREF="RM-3-5-1.html">3.5.1</A>), and a function can
be declared with an <FONT FACE="Arial, Helvetica">operator_symbol</FONT>
as its name (see <A HREF="RM-6-1.html">6.1</A>).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1286"></A>The syntax rules use the
terms <FONT FACE="Arial, Helvetica">defining_identifier</FONT>, <FONT FACE="Arial, Helvetica">defining_character_literal</FONT>,
and <FONT FACE="Arial, Helvetica">defining_operator_symbol</FONT> for
the defining occurrence of a name; these are collectively called <I>defining
names</I>. <A NAME="I1287"></A>The terms <FONT FACE="Arial, Helvetica">direct_name</FONT>
and <FONT FACE="Arial, Helvetica">selector_name</FONT> are used for usage
occurrences of <FONT FACE="Arial, Helvetica">identifier</FONT>s, <FONT FACE="Arial, Helvetica">character_literal</FONT>s,
and <FONT FACE="Arial, Helvetica">operator_symbol</FONT>s. These are
collectively called <I>usage names</I>. </DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1288"></A>The process by which a construct
achieves its run-time effect is called <I>execution</I>. <A NAME="I1289"></A><A NAME="I1290"></A>This
process is also called <I>elaboration</I> for declarations and <I>evaluation</I>
for expressions. One of the terms execution, elaboration, or evaluation
is defined by this International Standard for each construct that has
a run-time effect. </DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>1 <A NAME="I1291"></A>At
compile time, the declaration of an entity <I>declares</I> the entity.
<A NAME="I1292"></A>At run time, the elaboration of the declaration <I>creates</I>
the entity. </FONT></DIV>
<HR>
<P><A HREF="RM-TOC.html">Contents</A> <A HREF="RM-0-29.html">Index</A> <A HREF="RM-3.html">Previous</A> <A HREF="RM-3-2.html">Next</A> <A HREF="RM-TTL.html">Legal</A></P>
</BODY>
</HTML>
|