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=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 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!aioe.org!.POSTED!not-for-mail From: anon@att.net Newsgroups: comp.lang.ada Subject: Re: Position of "use" Date: Thu, 10 Jul 2014 01:27:08 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: <33fbd821-cb30-4be9-93c1-17002470413e@googlegroups.com> Reply-To: anon@att.net NNTP-Posting-Host: GL3Pv0vfEtiOLJK7l154Jw.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: IBM NewsReader/2 2.0 Xref: news.eternal-september.org comp.lang.ada:20831 Date: 2014-07-10T01:27:08+00:00 List-Id: Actually, the comments for compilation_unit 4 are correct under multiple compilation_unit type files, which GNAT does not support. It was tested under AdaEd-1.11.0a compiled for SuSE Linux, before I posted a condensed version. Note: GNAT (Adacore or GNU) does not support multiple compilation_unit (s) within one file. For multiple compilation_unit, likes those files found in ACVC, the external visibility starts with the "with_clause" and that clause grants all succeeding compilation_unit(s) access to that package or routine no matter how many compilation_unit there are. In other words you only need one "with_clause" for Ada compilers that support multiple compilation_unit in the same file. But the direct visibility is allowed by the "use_clause". Exception is where two or more routines from two sources are the same. Example is GNAT.IO.Put ( S : String ) and Ada.Text_IO.Put ( Item : in String ) In this case the compiler requires help to link to the correct package with requires a "selected_component" type statement to correctly identify the correct routine. Under Ada the following should work but some versions of GNAT over the years have not match the formal_parameter of two or more routines correctly when using two unique packages. Put ( S => ) ; -- GNAT.IO Put ( Item => ) ; -- Ada.Text_IO so it better just to use GNAT.IO.Put ( ) -- or Ada.Text_IO.Put ( ) or GNAT.IO.Put ( S => ) -- or Ada.Text_IO.Put ( Item => ) In <33fbd821-cb30-4be9-93c1-17002470413e@googlegroups.com>, Adam Beneschan writes: >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