comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: Common ancestor (visibility rules)
Date: 2000/03/30
Date: 2000-03-30T20:27:36+00:00	[thread overview]
Message-ID: <38E3B8B8.55305DCB@averstar.com> (raw)
In-Reply-To: 8bvjo3$n1k$1@nnrp1.deja.com

dmitry6243@my-deja.com wrote:
> 
> In article <8bu64t$60h$1@nnrp1.deja.com>,
> Robert Dewar <robert_dewar@my-deja.com> wrote:
> 
> > > with A; use A; -- OK with Aonix, error in GNAT
> > >(v3.12)
> >
> > The above is perfectly fine, and compiles fine with all versions
> > of GNAT, you are either compiling code different from what
> > you quoted, or you have a messed up copy of GNAT.
> 
> b-a.adb:1:13: "A" is not a usable package
> In other words:
> 
> 1. Fully qualified names cannot be used in WITH clause;
> 2. Fully qualified names can be used in USE clause;

GNAT has led you astray.  There appears to be a bug in GNAT.
The Aonix compiler is correct in accepting:

   with A; use A;

and in rejecting

   with A; use Standard.A;


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.

The visibility rules in context clauses are given in RM95 10.1.6
"Environment-Level Visibility Rules."  The visibility rules are
independent of the compilation unit that follows (though the
*legality* rule 10.1.2(8) does depend on the compilation unit).
The reason for these special visibility rules is that they
are for a clause that precedes the compilation unit, and may affect
some of the names used within the compilation unit spec,
so there is a potential chicken-and-egg problem if the visibility
in context clauses depended on the compilation unit that followed.

In any case, the basic rule is that *all* names used in a context
clause must be "full" expanded names, but *omitting* the
"Standard." part.  No hiding can happen, since only full names
are allowed, all of which start at the same point in the name space
(immediately within package Standard).  In fact, "with Standard.A;" would
be interpreted as requesting that the library unit whose
name-from-the-very-root is Standard.Standard.A be made visible.

Once you get inside a compilation unit, the rules are different,
and full expanded names are not required, though they may be
used to overcome name hiding.  And names-from-the-very-root (i.e.
those that start with Standard) may also be used.  But as mentioned
above, such names may *not* be used in context clauses.

> Here "fully qualified name" stays for a name beginning from Standard (I
> mean the predefined one). As a consequence, WITH and USE clauses use
> different names. This is what I meant talking about "two diffrent kinds
> of names".
> 
> Had I figured it out? (:-))

As mentioned above, GNAT has misled you.  The WITH and USE clauses
that appear in a context clause both obey the "environment-level"
visibility rules given in 10.1.6, with the added proviso that a USE
clause can only mention a unit that has already been mentioned in
a prior WITH clause.

>
> P.S. You know it for sure. Does ALRM cease to exist? It worked much
> better to me. I cannot find a new version, mine is dated 1992! (:-().

There is a publically available ALRM on various web sites, including:

   http://www.adaic.org/standards/ada95.html
> 
> Regards,
> Dmitry Kazakov
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




  reply	other threads:[~2000-03-30  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
2000-03-30  0:00         ` Robert Dewar
2000-03-30  0:00           ` dmitry6243
2000-03-30  0:00             ` Tucker Taft [this message]
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