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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Selected Components</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-4-1-2.html">Previous</A> <A HREF="AA-4-1-4.html">Next</A></P>
<HR>
<H1> 4.1.3 Selected Components</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [<FONT FACE="Arial, Helvetica">Selected_component</FONT>s
are used to denote components (including discriminants), entries, entry
families, and protected subprograms; they are also used as expanded names
as described below. <A NAME="I2305"></A>]</DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">selected_component<A NAME="I2306"></A>
::= </FONT><A NAME="I2307"></A><FONT FACE="Arial, Helvetica">prefix</FONT> . <A NAME="I2308"></A><FONT FACE="Arial, Helvetica">selector_name</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">selector_name<A NAME="I2309"></A>
::= </FONT><A NAME="I2310"></A><FONT FACE="Arial, Helvetica">identifier</FONT> | <A NAME="I2311"></A><FONT FACE="Arial, Helvetica">character_literal</FONT> | <A NAME="I2312"></A><FONT FACE="Arial, Helvetica">operator_symbol</FONT></DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2313"></A>A <FONT FACE="Arial, Helvetica">selected_component</FONT>
is called an <I>expanded name</I> if, according to the visibility rules,
at least one possible interpretation of its <FONT FACE="Arial, Helvetica">prefix</FONT>
denotes a package or an enclosing named construct (directly, not through
a <FONT FACE="Arial, Helvetica">subprogram_renaming_declaration</FONT>
or <FONT FACE="Arial, Helvetica">generic_renaming_declaration</FONT>).
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>See AI83-00187.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">selected_component</FONT>
that is not an expanded name shall resolve to denote one of the following:
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>If the <FONT FACE="Arial, Helvetica">prefix</FONT>
of a <FONT FACE="Arial, Helvetica">selected_component</FONT> denotes
an enclosing named construct, then the <FONT FACE="Arial, Helvetica">selected_component</FONT>
is interpreted only as an expanded name, even if the named construct
is a function that could be called without parameters. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A component [(including a discriminant)]:</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<UL Class="Bulleted">The <FONT FACE="Arial, Helvetica">prefix</FONT>
shall resolve to denote an object or value of some non-array composite
type (after any implicit dereference). The <FONT FACE="Arial, Helvetica">selector_name</FONT>
shall resolve to denote a <FONT FACE="Arial, Helvetica">discriminant_specification</FONT>
of the type, or, unless the type is a protected type, a <FONT FACE="Arial, Helvetica">component_declaration</FONT>
of the type. The <FONT FACE="Arial, Helvetica">selected_component</FONT>
denotes the corresponding component of the object or value. </UL>
<DIV Class="Paranum"><FONT SIZE=-2>7.a/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The components
of a protected object cannot be named except by an expanded name, even
from within the corresponding protected body. The protected body may
not reference <S>the </S>the private components of some arbitrary object
of the protected type; the protected body may reference components of
the current instance only (by an expanded name or a <FONT FACE="Arial, Helvetica">direct_name</FONT>).
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Only the
discriminants and components visible at the place of the <FONT FACE="Arial, Helvetica">selected_component</FONT>
can be selected, since a <FONT FACE="Arial, Helvetica">selector_name</FONT>
can only denote declarations that are visible (see <A HREF="AA-8-3.html">8.3</A>).
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A single entry, an entry family, or a protected subprogram:</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<UL Class="Bulleted">The <FONT FACE="Arial, Helvetica">prefix</FONT>
shall resolve to denote an object or value of some task or protected
type (after any implicit dereference). The <FONT FACE="Arial, Helvetica">selector_name</FONT>
shall resolve to denote an <FONT FACE="Arial, Helvetica">entry_declaration</FONT>
or <FONT FACE="Arial, Helvetica">subprogram_declaration</FONT> occurring
(implicitly or explicitly) within the visible part of that type. The
<FONT FACE="Arial, Helvetica">selected_component</FONT> denotes the corresponding
entry, entry family, or protected subprogram. </UL>
<DIV Class="Paranum"><FONT SIZE=-2>9.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This explicitly
says ``visible part'' because even though the body has visibility on
the private part, it cannot call the private operations of some arbitrary
object of the task or protected type, only those of the current instance
(and expanded name notation has to be used for that). </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal"> An expanded name shall resolve to denote a declaration
that occurs immediately within a named declarative region, as follows:
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The <FONT FACE="Arial, Helvetica">prefix</FONT> shall resolve
to denote either a package [(including the current instance of a generic
package, or a rename of a package)], or an enclosing named construct.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The <FONT FACE="Arial, Helvetica">selector_name</FONT>
shall resolve to denote a declaration that occurs immediately within
the declarative region of the package or enclosing construct [(the declaration
shall be visible at the place of the expanded name -- see <A HREF="AA-8-3.html">8.3</A>)].
The expanded name denotes that declaration. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Hence, a
library unit or subunit can use an expanded name to refer to the declarations
within the private part of its parent unit, as well as to other children
that have been mentioned in <FONT FACE="Arial, Helvetica">with_clause</FONT>s.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>If the <FONT FACE="Arial, Helvetica">prefix</FONT> does
not denote a package, then it shall be a <FONT FACE="Arial, Helvetica">direct_name</FONT>
or an expanded name, and it shall resolve to denote a program unit (other
than a package), the current instance of a type, a <FONT FACE="Arial, Helvetica">block_statement</FONT>,
a <FONT FACE="Arial, Helvetica">loop_statement</FONT>, or an <FONT FACE="Arial, Helvetica">accept_statement</FONT>
(in the case of an <FONT FACE="Arial, Helvetica">accept_statement</FONT>
or <FONT FACE="Arial, Helvetica">entry_body</FONT>, no family index is
allowed); the expanded name shall occur within the declarative region
of this construct. Further, if this construct is a callable construct
and the <FONT FACE="Arial, Helvetica">prefix</FONT> denotes more than
one such enclosing callable construct, then the expanded name is ambiguous,
independently of the <FONT FACE="Arial, Helvetica">selector_name</FONT>.</LI></UL>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2314"></A>The evaluation of a <FONT FACE="Arial, Helvetica">selected_component</FONT>
includes the evaluation of the <FONT FACE="Arial, Helvetica">prefix</FONT>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Normal"> <A NAME="I2315"></A><A NAME="I2316"></A>For a
<FONT FACE="Arial, Helvetica">selected_component</FONT> that denotes
a component of a <FONT FACE="Arial, Helvetica">variant</FONT>, a check
is made that the values of the discriminants are such that the value
or object denoted by the <FONT FACE="Arial, Helvetica">prefix</FONT>
has this component. <A NAME="I2317"></A><A NAME="I2318"></A>The exception
Constraint_Error is raised if this check fails. </DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Examples of
selected components:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT> Tomorrow.Month <I>-- a record component (see <A HREF="AA-3-8.html">3.8</A>)</I><BR>
Next_Car.Owner <I>-- a record component (see <A HREF="AA-3-10-1.html">3.10.1</A>)</I><BR>
Next_Car.Owner.Age <I>-- a record component (see <A HREF="AA-3-10-1.html">3.10.1</A>)</I><BR>
<I>-- the previous two lines involve implicit dereferences</I><BR>
Writer.Unit <I>-- a record component (a discriminant) (see <A HREF="AA-3-8-1.html">3.8.1</A>)</I><BR>
Min_Cell(H).Value <I>-- a record component of the result (see <A HREF="AA-6-1.html">6.1</A>)</I><BR>
<I>-- of the function call Min_Cell(H)</I><BR>
Control.Seize <I>-- an entry of a protected object (see <A HREF="AA-9-4.html">9.4</A>)</I><BR>
Pool(K).Write <I>-- an entry of the task Pool(K) (see <A HREF="AA-9-4.html">9.4</A>)</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em"> <I>Examples of expanded
names:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT> Key_Manager."<" <I>-- an operator of the visible part of a package (see <A HREF="AA-7-3-1.html">7.3.1</A>)</I><BR>
Dot_Product.Sum <I>-- a variable declared in a function body (see <A HREF="AA-6-1.html">6.1</A>)</I><BR>
Buffer.Pool <I>-- a variable declared in a protected unit (see <A HREF="AA-9-11.html">9.11</A>)</I><BR>
Buffer.Read <I>-- an entry of a protected unit (see <A HREF="AA-9-11.html">9.11</A>)</I><BR>
Swap.Temp <I>-- a variable declared in a block statement (see <A HREF="AA-5-6.html">5.6</A>)</I><BR>
Standard.Boolean <I>-- the name of a predefined type (see <A HREF="AA-A-1.html">A.1</A>)</I></TT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>19.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I2319"></A>We now allow
an expanded name to use a prefix that denotes a rename of a package,
even if the selector is for an entity local to the body or private part
of the package, so long as the entity is visible at the place of the
reference. This eliminates a preexisting anomaly where references in
a package body may refer to declarations of its visible part but not
those of its private part or body when the prefix is a rename of the
package. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>19.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The syntax rule for <FONT FACE="Arial, Helvetica">selector_name</FONT>
is new. It is used in places where visibility, but not necessarily direct
visibility, is required. See <A HREF="AA-4-1.html">4.1</A>, ``<A HREF="AA-4-1.html">Names</A>''
for more information.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The description of dereferencing
an access type has been moved to <A HREF="AA-4-1.html">4.1</A>, ``<A HREF="AA-4-1.html">Names</A>'';
<FONT FACE="Arial, Helvetica">name</FONT>.<B>all</B> is no longer considered
a <FONT FACE="Arial, Helvetica">selected_component</FONT>.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The rules have been restated to
be consistent with our new terminology, to accommodate class-wide types,
etc. </FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-4-1-2.html">Previous</A> <A HREF="AA-4-1-4.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|