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 Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.etla.org!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: Position of "use" Date: Wed, 09 Jul 2014 01:39:51 +0300 Organization: Aioe.org NNTP Server Message-ID: References: <89f04209-3cb5-47c5-b69a-a516df2437de@googlegroups.com> NNTP-Posting-Host: BISA/P8IHJbAM3ms471zeQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.12.4 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.dca.giganews.com comp.lang.ada:187466 Date: 2014-07-09T01:39:51+03:00 List-Id: Adam Beneschan wrote: > On Friday, July 4, 2014 11:43:46 PM UTC-7, Victor Porton wrote: >> What is the difference between >> >> with X; use X; >> package Y is >> end Y; >> >> and >> >> with X; >> package Y is >> use X; >> end Y; >> >> ? > > OK, I've looked into it, and there's no difference. I'm assuming that > there may be more code in the specification of Y, but that in the second > example, "use X" is the first thing in this specification. > > RM 8.4(6-7) describe the "scope" of a use_clause, which is the portion of > code that is affected by the "use". If it's in the context clause, the > scope is the entire declarative region of the package. If it's inside the > declarative region, the scope is the part of the declarative region > starting from 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), that means that the scope is the entire declarative region > of the package, same 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 > is 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 it contains special rules for context clauses. > Nothing in those rules says that "use" makes anything visible in a context > clause; therefore, a "use" in 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 clause on a child package or subunit). > > Therefore, the effect of a "use" that is the first thing in a package > specification has the exact same effect as a "use" appearing in the > context clause. > > -- Adam Possible reason why these two equal variants of syntax were introduced by Ada designers: It would be different if we'd replace package with a procedure or a function, because use can apply or not apply to procedure parameters. The same applies to generic packages. -- Victor Porton - http://portonvictor.org