From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.42.235.8 with SMTP id ke8mr19188381icb.22.1404847841122; Tue, 08 Jul 2014 12:30:41 -0700 (PDT) X-Received: by 10.50.88.9 with SMTP id bc9mr137144igb.14.1404847841020; Tue, 08 Jul 2014 12:30:41 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!hn18no435751igb.0!news-out.google.com!gf2ni0igb.0!nntp.google.com!uq10no250861igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 8 Jul 2014 12:30:40 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <89f04209-3cb5-47c5-b69a-a516df2437de@googlegroups.com> Subject: Re: Position of "use" From: Adam Beneschan Injection-Date: Tue, 08 Jul 2014 19:30:41 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:20810 Date: 2014-07-08T12:30:40-07:00 List-Id: On Friday, July 4, 2014 11:43:46 PM UTC-7, Victor Porton wrote: > What is the difference between >=20 > with X; use X; > package Y is > end Y; >=20 > and >=20 > with X; > package Y is > use X; > end Y; >=20 > ? OK, I've looked into it, and there's no difference. I'm assuming that ther= e may be more code in the specification of Y, but that in the second exampl= e, "use X" is the first thing in this specification. =20 RM 8.4(6-7) describe the "scope" of a use_clause, which is the portion of c= ode that is affected by the "use". If it's in the context clause, the scop= e is the entire declarative region of the package. If it's inside the decl= arative region, the scope is the part of the declarative region starting fr= om the "use" and ending at the end of the declarative region; if the "use" = clause is the first thing in the region (as in the second example above), t= hat means that the scope is the entire declarative region of the package, s= ame as the first example. (Note that in both cases, the declarative region= will include child packages, if any. This follows from the rules in RM 8.= 1.) The scope doesn't include the context clause itself. (The context clause i= s the "with" and "use" statements that occur before the "package/procedure/= function" of a top-level library unit, and it may include pragmas.) RM 10.= 1.6 says that the visibility rules don't apply to the context clause, and i= t contains special rules for context clauses. Nothing in those rules says = that "use" makes anything visible in a context clause; therefore, a "use" i= n a context clause has no effect on any other "with", "use", or "pragma" in= the context clause, or in any other context clause (i.e. the context claus= e on a child package or subunit).=20 Therefore, the effect of a "use" that is the first thing in a package speci= fication has the exact same effect as a "use" appearing in the context clau= se. -- Adam