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.7 required=5.0 tests=BAYES_00,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: dmitry6243@my-deja.com Subject: Re: Common ancestor (visibility rules) Date: 2000/03/29 Message-ID: <8bt42b$tfe$1@nnrp1.deja.com> X-Deja-AN: 603859898 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> X-Http-Proxy: 1.0 x25.deja.com:80 (Squid/1.1.22) for client 212.79.192.251 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Mar 29 14:30:34 2000 GMT X-MyDeja-Info: XMYDJUIDdmitry6243 Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.72 [en] (WinNT; I) Date: 2000-03-29T00:00:00+00:00 List-Id: In article <8bskgp$ctu$1@nnrp1.deja.com>, Robert Dewar wrote: > In article <8bsgpf$96f$1@nnrp1.deja.com>, > dmitry6243@my-deja.com wrote: > > > In article <8bq726$lo8$1@nnrp1.deja.com>, > > Robert Dewar wrote: > > > > > No need to invent a new name, it is called Standard > > > > > > Then package A could be specified as > > > > Root.A and A's Foo as Root.A.Foo. > > > > Yes, "Standard" was actually my first attempt, > > Well you have got yourself quite confused here. There are two > ways of doing things. You either use a USE statement, or you > qualify the name. Your original post was about the second > attempt, and the proper form is simply > > Standard.A.Foo; > > Now if you want to use a USE statement, you have a much simpler > form for a-b.adb: > > with A; use A; > separate (B) > procedure A is > begin > Foo; > end A; I must give a bit more backgroud of what I am doing. I am trying to make the code compiled by both Aonix and GNAT. So, the result is with A; use A; -- OK with Aonix, error in GNAT (v3.12) with A; use Standard.A; -- Error in Aonix, OK with GNAT Therefore my question, what is correct. > and that of course is perfectly fine, since the "use A" makes > Foo visible. > > > but I tried the following > > > with Standard.A; use Standard.A; > > No, that's completely wrong, why, because you can only WITH > a library unit, and Standard is NOT a library unit, it is the > ancestor of all library units, a library unit is PRECISELY > something which is a *child* of standard, and standard is > definitely not its own child! I.e. Standard is a unit, but not a library unit. Then there seems to be two arts of unit names: library names starting with Standard that can be *used* but not *withed*, then "un-library" names without Standard prefix. They can be *withed* and sometimes *used*. Right? > > The correct version is: > > -------------------- b-a.adb > > with A; use Standard.A; > > No, that is not the correct version (though it is legal). > The Standard. prefix here is odd and completely unnecessary > in all circumstances in a use clause. It is works in GNAT and illegal in Aonix, but see above. > > I must say, that the difference is rather subtle. > > Not subtle at all once you have the right model, which is > that there is Standard at the outer level, and then all the > library units are children of Standard. > > > Perhaps compiler should first > > search for physical childs of Standard and then in case of > > failure, discard the "Standard" prefix, so that: > > > > with Standard.A; use Standard.A; > > > > would be correct? > > No, that would > > a) be a very confusing rule once you understand things I am afraid "with A; use Standard.A;" is much more confusing. > b) be totally unnecessary, since you can always write > this as: > > with A; use A; > > which is the obvious convenient and useful way to write this. So GNAT is wrong? > c) would cause confusion and ambiguity as further explored > below. I do not see how. Either Standard.A is the name of A or not. If yes then why "with Standard.A;" is illegal. If not, why "use Standard.A;" is legal. > The only time you need an explicit prefix of Standard is when > you are trying to reference an outer entity of the same name > as an inner entity by explicit qualification. In fact this > very rarely happens, why? because it is generally very bad > style to reuse names this way. In your little example, you > are operating in an environment where the code knows that > A is a library unit, and intends to use a procedure from > A. It is not illegal, but it *is* bad practice and confusing > to use this same name A for one of your procedures in this > region. It is disputable. The original program has two packages: Lines and Segmentation. Segmentation does not depend on Lines. It has a child Segmentation.Lines which collects all methods that rely on Lines. An attempt to write a separate procedure for Segmentation.Lines caused the problem. > By the way, it is under some circumstances legal (though very > bad practice to write) > > with Standard.A; > > If you really understand things by now, you should be able to > figure out the conditions. > > We can only *with* a library unit, so the above is legal only > if there is a library unit Standard and a child Standard.A. It is clear that there is no need to *with* Standard for it is always *withed*. The question is what the name of a library unit is. Does it include "Standard." as prefix or not. IF the fully qualified name of A is Standard.A, then "with Standard.A; use Standard.A;" SHALL be correct. > Well we learned from above that the Standard that is in the RM > is NOT a library unit, but rather the parent of all library > units, so the above must imply that there is another Standard > that is a library unit. If it is not a unit, not a thing, why does it have a name? Something that does not exist need not to be specified. Regards, Dmitry Kazakov Sent via Deja.com http://www.deja.com/ Before you buy.