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.236.66.178 with SMTP id h38mr9675037yhd.44.1404918867604; Wed, 09 Jul 2014 08:14:27 -0700 (PDT) X-Received: by 10.50.254.1 with SMTP id ae1mr277094igd.2.1404918867496; Wed, 09 Jul 2014 08:14:27 -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!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!m5no385162qaj.1!news-out.google.com!gf2ni1igb.0!nntp.google.com!hn18no902376igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 9 Jul 2014 08:14:26 -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: <33fbd821-cb30-4be9-93c1-17002470413e@googlegroups.com> Subject: Re: Position of "use" From: Adam Beneschan Injection-Date: Wed, 09 Jul 2014 15:14:27 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:20829 Date: 2014-07-09T08:14:26-07:00 List-Id: On Wednesday, July 9, 2014 3:36:09 AM UTC-7, an...@att.net wrote: > For Ada compilers, where you can have more than one compilation_unit=20 > within one file (RM 10.1 -- 10.1.1), it allows all preceding=20 > compilation_unit to have access the same library with only one=20 > "with_clause" without sharing global visibility to that package. >=20 > Note: GNAT limits the compilation_unit to one per file. But GNAT still= =20 > allows this type of program design. Putting the "with_clause" in the=20 > specification file (.ads) allows access for the corresponding body file= =20 > (.adb) in some cases without having the "with_clause" in the body file. I'm not sure what you're trying to say here, but I want to reiterate: accor= ding to the Ada rules, putting multiple compilation units in the same file = has *no* effect on the visibility rules (or any other rules). If you have = package specifications for two different packages, P1 and P2, in the same f= ile, a "with" or "use" clause on P1 does not apply to P2, and vice versa. A "with" clause on a specification of any package automatically applies to = the body, and it also automatically applies to any child unit specification= s or bodies. This is due to the rules in RM 8.1 and has nothing to do with= GNAT, and nothing to do with whether the specification and body are in the= same file or not. Thus, in this example, the comments are wrong: > -- > -- compilation_unit 4 : Limits visibility to Text_IO to a=20 > -- "selected_component", unless the=20 > -- global "use_clause" is used. > -- > -- example : Text_IO.New_Line ; > -- > package Test_Cal is > -- ... > end Test_Cal ; Text_IO is not visible at all, since there is no "with Text_IO" on Test_Cal= . The "with Text_IO" earlier in the file, on "package Test_55", has no eff= ect. -- Adam