comp.lang.ada
 help / color / mirror / Atom feed
From: dmitry6243@my-deja.com
Subject: Re: Common ancestor (visibility rules)
Date: 2000/03/29
Date: 2000-03-29T00:00:00+00:00	[thread overview]
Message-ID: <8bt42b$tfe$1@nnrp1.deja.com> (raw)
In-Reply-To: 8bskgp$ctu$1@nnrp1.deja.com

In article <8bskgp$ctu$1@nnrp1.deja.com>,
Robert Dewar <dewar@gnat.com> wrote:

> In article <8bsgpf$96f$1@nnrp1.deja.com>,
> dmitry6243@my-deja.com wrote:
>
> > In article <8bq726$lo8$1@nnrp1.deja.com>,
> > Robert Dewar <robert_dewar@my-deja.com> 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.




  reply	other threads:[~2000-03-29  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-28  0:00 Common ancestor (visibility rules) dmitry6243
2000-03-28  0:00 ` Steve Folly
2000-03-28  0:00 ` Robert Dewar
2000-03-29  0:00   ` dmitry6243
2000-03-29  0:00     ` Robert Dewar
2000-03-29  0:00       ` dmitry6243 [this message]
2000-03-30  0:00         ` Robert Dewar
2000-03-30  0:00           ` dmitry6243
2000-03-30  0:00             ` Tucker Taft
2000-03-31  0:00               ` dmitry6243
2000-04-01  0:00               ` Robert Dewar
2000-04-01  0:00               ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox