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,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,44aecd08962a2500 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-07 10:29:08 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3EE220D1.2010608@spam.com> From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Visibility References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 07 Jun 2003 17:29:29 GMT NNTP-Posting-Host: 63.184.104.239 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1055006969 63.184.104.239 (Sat, 07 Jun 2003 10:29:29 PDT) NNTP-Posting-Date: Sat, 07 Jun 2003 10:29:29 PDT Xref: archiver1.google.com comp.lang.ada:38787 Date: 2003-06-07T17:29:29+00:00 List-Id: And838N@netscape.net wrote: > > visibilitytest.adb:18:23: "count" is not visible > visibilitytest.adb:18:23: multiple use clauses cause hiding > visibilitytest.adb:18:23: hidden declaration at a-textio.ads:66 > visibilitytest.adb:18:23: hidden declaration at a-strunb.ads:217 > visibilitytest.adb:18:23: hidden declaration at a-strunb.ads:211 > visibilitytest.adb:18:23: hidden declaration at a-strunb.ads:205 > gnatmake: "visibilitytest.adb" compilation error > > To me, GNAT should be able to resolve which > count to use because the count in ada.strings.unbounded is a function > and count in ada.text_io is a type. Not to mention the function > returns (or is of type) Natural, not count. This message does not say that GNAT cannot resolve which Count you mean. It says that, according to the rules of the language, Count is not visible because multiple use causes cause hiding. The language requires that the compiler not resolve this use of Count. In some other hypothetical language (let's call it Dad) the compiler may be allowed to resolve any such issues that it can, and only complain about those it cannot resolve. That would be perfectly fine for Dad, but not for Ada, because Ada strives for portability. If the language does not define what kinds of things the compiler may resolve, then different compilers may give different results on the same source, with one compiler resolving such an issue while another cannot. > The answer to my question was in Cohen's book, chapter 10. The > rules for the "with" clause and packages are to make a large > number of files easier to manage and to make it clear to the reader > what is going on with any particular file. The "with" clause just > makes "stuff" visible; it is up to the programmer/engineer to specify > or clarify, by using an expanded name, what facilities they are "use" > ing from a particular package. Thus, GNAT's compiler message tells > me not that GNAT can't determine which count to use but that I need > to specify, for future readers, which count I needed. In doing so > ,if I am searching for count, I narrow the search to the exact > package I need to look in for the count I "used". Context clauses ("with") have nothing to do with files. The things named in context clauses are compilation units. There is no correlation between compilation units and files in the language (GNAT enforces such a correlation because of its compilation model, but that's an implementation rule, not a language rule). The "with" makes the compilation unit visible. If the compilation unit is a package, one may use dot notation to refer to the declarations in its visible part. The "use" makes the declarations in a package's visible part directly visible, except where it causes hiding, in which case it does not. -- Jeff Carter "I would never want to belong to any club that would have someone like me for a member." Annie Hall