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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Scope 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-8-1.html">Previous</A> <A HREF="AA-8-3.html">Next</A></P>
<HR>
<H1> 8.2 Scope of Declarations</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [For each declaration, the language rules define
a certain portion of the program text called the <I>scope</I> of the
declaration. The scope of a declaration is also called the scope of any
view or entity declared by the declaration. Within the scope of an entity,
and only there, there are places where it is legal to refer to the declared
entity. These places are defined by the rules of visibility and overloading.]
</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="I3328"></A>The
<I>immediate scope</I> of a declaration is a portion of the declarative
region immediately enclosing the declaration. The immediate scope starts
at the beginning of the declaration, except in the case of an overloadable
declaration, in which case the immediate scope starts just after the
place where the profile of the callable entity is determined (which is
at the end of the <FONT FACE="Arial, Helvetica">_specification</FONT>
for the callable entity, or at the end of the <FONT FACE="Arial, Helvetica">generic_instantiation</FONT>
if an instance). The immediate scope extends to the end of the declarative
region, with the following exceptions: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The reason for
making overloadable declarations with profiles special is to simplify
compilation: until the compiler has determined the profile, it doesn't
know which other declarations are homographs of this one, so it doesn't
know which ones this one should hide. Without this rule, two passes over
the <FONT FACE="Arial, Helvetica">_specification</FONT> or <FONT FACE="Arial, Helvetica">generic_instantiation</FONT>
would be required to resolve names that denote things with the same name
as this one. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The immediate scope of a <FONT FACE="Arial, Helvetica">library_item</FONT>
includes only its semantic dependents. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>3.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>Section 10 defines
only a partial ordering of <FONT FACE="Arial, Helvetica">library_item</FONT>s.
Therefore, it is a good idea to restrict the immediate scope (and the
scope, defined below) to semantic dependents.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.b</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1>Consider
also examples like this: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.c</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B> P <B>is</B> <B>end</B> P;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.d</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B> P.Q <B>is</B><BR>
I : Integer := 0;<BR>
<B>end</B> P.Q;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.e/1</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>with</B> P;<BR>
<B>package</B> R <B>is</B><BR>
<B>package</B> X <B>renames</B> P;<BR>
<U>J : Integer := </U>X.Q.I<S> := 17</S>; --<I> Illegal!</I><BR>
<B>end</B> R;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.f</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The scope of P.Q does not contain
R. Hence, neither P.Q nor X.Q are visible within R. However, the name
R.X.Q would be visible in some other library unit where both R and P.Q
are visible (assuming R were made legal by removing the offending declaration).
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The immediate scope of a declaration in the private part
of a library unit does not include the visible part of any public descendant
of that library unit. <A NAME="I3329"></A></LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>4.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>In other
words, a declaration in the private part can be visible within the visible
part, private part and body of a private child unit. On the other hand,
such a declaration can be visible within only the private part and body
of a public child unit. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The purpose of
this rule is to prevent children from giving private information to clients.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>For a public
child subprogram, this means that the parent's private part is not visible
in the <FONT FACE="Arial, Helvetica">formal_part</FONT>s of the declaration
and of the body. This is true even for <FONT FACE="Arial, Helvetica">subprogram_bodies</FONT>
that are not completions. For a public child generic unit, it means that
the parent's private part is not visible in the <FONT FACE="Arial, Helvetica">generic_formal_part</FONT>,
as well as in the first list of <FONT FACE="Arial, Helvetica">basic_declarative_item</FONT>s
(for a generic package), or the <FONT FACE="Arial, Helvetica">formal_part</FONT>(s)
(for a generic subprogram). </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3330"></A>[The <I>visible part</I> of
(a view of) an entity is a portion of the text of its declaration containing
declarations that are visible from outside.] <A NAME="I3331"></A>The
<I>private part</I> of (a view of) an entity that has a visible part
contains all declarations within the declaration of (the view of) the
entity, except those in the visible part; [these are not visible from
outside. Visible and private parts are defined only for these kinds of
entities: callable entities, other program units, and composite types.]
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC><A NAME="I3332"></A>The visible part of a view of a callable
entity is its profile.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC><A NAME="I3333"></A>The visible part of a composite type
other than a task or protected type consists of the declarations of all
components declared [(explicitly or implicitly)] within the <FONT FACE="Arial, Helvetica">type_declaration</FONT>.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC><A NAME="I3334"></A>The visible part of a generic unit
includes the <FONT FACE="Arial, Helvetica">generic_formal_part</FONT>.
For a generic package, it also includes the first list of <FONT FACE="Arial, Helvetica">basic_declarative_item</FONT>s
of the <FONT FACE="Arial, Helvetica">package_specification</FONT>. For
a generic subprogram, it also includes the profile. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>8.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>Although there
is no way to reference anything but the formals from outside a generic
unit, they are still in the visible part in the sense that the corresponding
declarations in an instance can be referenced (at least in some cases).
In other words, these declarations have an effect on the outside world.
The visible part of a generic unit needs to be defined this way in order
to properly support the rule that makes a parent's private part invisible
within a public child's visible part. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The visible
part of an instance of a generic unit is as defined for packages and
subprograms; it is not defined in terms of the visible part of a generic
unit. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>[The visible part of a package, task unit, or protected
unit consists of declarations in the program unit's declaration other
than those following the reserved word <B>private</B>, if any; see <A HREF="AA-7-1.html">7.1</A>
and <A HREF="AA-12-7.html">12.7</A> for packages, <A HREF="AA-9-1.html">9.1</A>
for task units, and <A HREF="AA-9-4.html">9.4</A> for protected units.]
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3335"></A>The scope of a declaration
always contains the immediate scope of the declaration. In addition,
for a given declaration that occurs immediately within the visible part
of an outer declaration, or is a public child of an outer declaration,
the scope of the given declaration extends to the end of the scope of
the outer declaration, except that the scope of a <FONT FACE="Arial, Helvetica">library_item</FONT>
includes only its semantic dependents. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Note the
recursion. If a declaration appears in the visible part of a library
unit, its scope extends to the end of the scope of the library unit,
but since that only includes dependents of the declaration of the library
unit, the scope of the inner declaration also only includes those dependents.
If X renames library package P, which has a child Q, a <FONT FACE="Arial, Helvetica">with_clause</FONT>
mentioning P.Q is necessary to be able to refer to X.Q, even if P.Q is
visible at the place where X is declared. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3336"></A>The immediate scope of a
declaration is also the immediate scope of the entity or view declared
by the declaration. <A NAME="I3337"></A>Similarly, the scope of a declaration
is also the scope of the entity or view declared by the declaration.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.a</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1><B>Ramification:
</B>The rule for immediate scope implies the following: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.b</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>If the declaration is that of a library unit, then the
immediate scope includes the declarative region of the declaration itself,
but not other places, unless they are within the scope of a <FONT FACE="Arial, Helvetica">with_clause</FONT>
that mentions the library unit.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11.c</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1>It is necessary to attach the
semantics of <FONT FACE="Arial, Helvetica">with_clause</FONT>s to [immediate]
scopes (as opposed to visibility), in order for various rules to work
properly. A library unit should hide a homographic implicit declaration
that appears in its parent, but only within the scope of a <FONT FACE="Arial, Helvetica">with_clause</FONT>
that mentions the library unit. Otherwise, we would violate the "legality
determinable via semantic dependences" rule of <A HREF="AA-10.html">10</A>,
``<A HREF="AA-10.html">Program Structure and Compilation Issues</A>''.
The declaration of a library unit should be allowed to be a homograph
of an explicit declaration in its parent's body, so long as that body
does not mention the library unit in a <FONT FACE="Arial, Helvetica">with_clause</FONT>.</FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11.d</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1>This means that one cannot denote
the declaration of the library unit, but one might still be able to denote
the library unit via another view.</FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11.e</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1>A <FONT FACE="Arial, Helvetica">with_clause</FONT>
does not make the declaration of a library unit visible; the lack of
a <FONT FACE="Arial, Helvetica">with_clause</FONT> prevents it from being
visible. Even if a library unit is mentioned in a <FONT FACE="Arial, Helvetica">with_clause</FONT>,
its declaration can still be hidden.</FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11.f</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>The completion of the declaration of a library unit (assuming
that's also a declaration) is not visible, neither directly nor by selection,
outside that completion.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11.g</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>The immediate scope of a declaration immediately within
the body of a library unit does not include any child of that library
unit.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11.h</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1>This is needed to prevent children
from looking inside their parent's body. The children are in the declarative
region of the parent, and they might be after the parent's body. Therefore,
the scope of a declaration that occurs immediately within the body might
include some children. </FONT></UL>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>4 There are notations for
denoting visible declarations that are not directly visible. For example,
<FONT FACE="Arial, Helvetica">parameter_specification</FONT>s are in
the visible part of a <FONT FACE="Arial, Helvetica">subprogram_declaration</FONT>
so that they can be used in named-notation calls appearing outside the
called subprogram. For another example, declarations of the visible part
of a package can be denoted by expanded names appearing outside the package,
and can be made directly visible by a <FONT FACE="Arial, Helvetica">use_clause</FONT>.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>There are
some obscure involving generics cases in which there is no such notation.
See Section 12. </FONT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>12.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I3338"></A>The fact that
the immediate scope of an overloadable declaration does not include its
profile is new to Ada 95. It replaces RM83-8.3(16), which said that within
a subprogram specification and within the formal part of an entry declaration
or accept statement, all declarations with the same designator as the
subprogram or entry were hidden from all visibility. The RM83-8.3(16)
rule seemed to be overkill, and created both implementation difficulties
and unnecessary semantic complexity. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>12.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We no longer need to talk about
the scope of notations, <FONT FACE="Arial, Helvetica">identifier</FONT>s,
<FONT FACE="Arial, Helvetica">character_literal</FONT>s, and <FONT FACE="Arial, Helvetica">operator_symbol</FONT>s.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The notion of "visible part"
has been extended in Ada 95. The syntax of task and protected units now
allows private parts, thus requiring us to be able to talk about the
visible part as well. It was necessary to extend the concept to subprograms
and to generic units, in order for the visibility rules related to child
library units to work properly. It was necessary to define the concept
separately for generic formal packages, since their visible part is slightly
different from that of a normal package. Extending the concept to composite
types made the definition of scope slightly simpler. We define visible
part for some things elsewhere, since it makes a big difference to the
user for those things. For composite types and subprograms, however,
the concept is used only in arcane visibility rules, so we localize it
to this clause.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.e</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>In Ada 83, the semantics of <FONT FACE="Arial, Helvetica">with_clause</FONT>s
was described in terms of visibility. It is now described in terms of
[immediate] scope.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.f</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1>We
have clarified that the following is illegal (where Q and R are library
units): </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.g</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B> Q <B>is</B><BR>
I : Integer := 0;<BR>
<B>end</B> Q;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.h</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>package</B> R <B>is</B><BR>
<B>package</B> X <B>renames</B> Standard;<BR>
X.Q.I := 17; --<I> Illegal!</I><BR>
<B>end</B> R;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.i</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>even though Q is declared in the
declarative region of Standard, because R does not mention Q in a <FONT FACE="Arial, Helvetica">with_clause</FONT>.
</FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-8-1.html">Previous</A> <A HREF="AA-8-3.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|