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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,84b1828b2b26fc4f X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Common ancestor (visibility rules) Date: 2000/04/01 Message-ID: <8c4taq$een$1@nnrp1.deja.com>#1/1 X-Deja-AN: 605233976 References: <8bprin$a37$1@nnrp1.deja.com> <8bq726$lo8$1@nnrp1.deja.com> <8bsgpf$96f$1@nnrp1.deja.com> <8bskgp$ctu$1@nnrp1.deja.com> <8bt42b$tfe$1@nnrp1.deja.com> <8bu64t$60h$1@nnrp1.deja.com> <8bvjo3$n1k$1@nnrp1.deja.com> <38E3B8B8.55305DCB@averstar.com> X-Http-Proxy: 1.0 x36.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Sat Apr 01 13:24:49 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-04-01T00:00:00+00:00 List-Id: In article <38E3B8B8.55305DCB@averstar.com>, Tucker Taft wrote: > It is true, but potentially confusing, that the visibility > rules in context clauses (the with and use clauses that come > in front of a compilation unit) and the visibility rules > inside of a compilation unit are different. Of course this is not normally an issue, except in this contorted subunit case, which shows exactly why the rule is the way it is. Actually I don't think the language is really confusing here, just the formal rules :-) "with A; use A;" is the natural way to write things in this case, and most programmers will write this without thinking about it. And indeed of course most programmers will avoid this kind of duplication of names anyway, though the example does realistically show how it could arise by "accident". Probably the history here is that dmitry first just wrote with A; use A; and then ran into trouble with the old version of GNAT. Then left out the troublesome "use A", then ran into trouble with not knowing to use Standard for the reference. My taste here would be to *avoid* the use of the use clause in any case. You really don't want to use USE clauses when you have this kind of confusion of names. The writer of the main unit here may not know about the clash of names for A, but the writer of the subunit sure does, and if there ever was a case where USE clauses should be avoided this is it, since you have two units around called A, and it will not be at all helpful to simply use A without making it clear which A you are talking about. Indeed I would be tempted in this situation not only to avoid the use clause, but also to qualify the subprogram A. In other words, given this name clash, I would always write B.A for the subprogram Standard.A for the library package That will help the reader of this subunit sort through the unfortunate name clash. Note that if you follow this advice the one place you cannot use B.A is in the spec of the subprogram itself, but that's OK since separate (B) is right there, and no confusion arises. P.S. It is indeed a real bug in GNAT that it accepts Standard.A. Certainly a rather obscure bug that might have layed dormant for a very long time :-) Sent via Deja.com http://www.deja.com/ Before you buy.