comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Common ancestor (visibility rules)
Date: 2000/04/01
Date: 2000-04-01T00:00:00+00:00	[thread overview]
Message-ID: <8c4taq$een$1@nnrp1.deja.com> (raw)
In-Reply-To: 38E3B8B8.55305DCB@averstar.com

In article <38E3B8B8.55305DCB@averstar.com>,
  Tucker Taft <stt@averstar.com> 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.




  parent reply	other threads:[~2000-04-01  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
2000-03-31  0:00               ` dmitry6243
2000-04-01  0:00               ` Robert Dewar [this message]
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