Version 1.1 of acs/ac-00018.txt

Unformatted version of acs/ac-00018.txt version 1.1
Other versions for file acs/ac-00018.txt

!standard 8.4(06)          01-11-07 AC95-00018/01
!class uninteresting 01-11-07
!status received 01-11-07
!subject Scope of use_clause
!summary
!appendix

From: Dan Eilers
Sent: Wednesday, November  7, 2001 1:26 PM

!topic scope of use_clause
!reference RM95-8.4/6
!from Dan Eilers 01-11-07
!discussion


   with Ada.Numerics;
   use Ada;
   use Numerics;   -- legal?
   package test is
   end test;


RM95-8.4/6 appears to say that the above use clause is not legal,
because "The scope [of a use_clause in a context clause] does not
include context_clauses themselves".

If my reading is correct, what is the purpose of this rule?

****************************************************************

From: Christoph Grein
Sent: Wednesday, November  7, 2001  11:53 PM

Visibility in context clauses is different from that inside of units.
E.g.

with X;
-- with Standard.X;  -- illegal here (except ... see below)
package P is
  Y: Standard.X.Something;  -- same as X.Something (except when X is hidden
                            -- somehow)
end P;

Standard in a context clause denotes a library unit Standard, thus the above
context clause would denote a child unit X of that Standard.

Note that the Ada "Standard" package is _not_ a library unit. Thus if your
example were legal, "use Ada" would hide any library unit Numerics that might
be around.

****************************************************************

From: Tucker Taft
Sent: Wednesday, November  7, 2001  4:42 PM

> If my reading is correct, what is the purpose of this rule?

This is to make understanding context clauses simpler, since they
only use full expanded names.

****************************************************************

From: Robert Duff
Sent: Tuesday, November 13, 2001  11:23 AM

Dan wrote:

> If my reading is correct, what is the purpose of this rule?

Your reading is correct.

This rule was inherited from Ada 83.  I agree that it's an annoyance.
In fact, I vaguely recall trying to get Tucker to change it during the
Ada 9X design, but he was deadset against changing it.  Since it's
"merely" an annoyance, why bother changing it now?

If I ran the circus, the context clauses would appear *inside* the
package, not dangling above it.  And the visibility rules for them would
allow the sorts of things you ask.  And the word "with" would be a
verb.  ;-)

And you could put them in the private part.  (Now that's a much more
important issue: if we're going to be meddling with this stuff, we
should solve *that* problem, rather than worrying about annoyances.)

Christoph wrote:

> Visibility in context clauses is different from that inside of units.
> E.g.

True, but...

> Note that the Ada "Standard" package is _not_ a library unit.

Actually, Standard *is* a library unit in Ada 95.  From 10.1.1:

1   [A library_item is a compilation unit that is the declaration, body, or
renaming of a library unit.  Each library unit (except Standard) has a parent
unit, which is a library package or generic library package.] {child (of a
library unit)} A library unit is a child of its parent unit.  The root
library units are the children of the predefined library package Standard.

        1.a   Ramification:  Standard is a library unit.
...
                         Wording Changes From Ada 83

        35.q   Standard is considered a library unit in Ada 9X.  This
        simplifies the descriptions, since it implies that the parent of each
        library unit is a library unit.  (Standard itself has no parent, of
        course.)  As in Ada 83, the language does not define any way to
        recompile Standard, since the name given in the declaration of a
        library unit is always interpreted in relation to Standard.  That is,
        an attempt to compile a package Standard would result in
        Standard.Standard.

>... Thus if your
> example were legal, "use Ada" would hide any library unit Numerics that might be
> around.

Umm, Ada.Numerics is a library unit, too.  I think you might be thinking
the term "root library unit", which refers to the (immediate) children of
Standard, but not to Standard itself, and not to [great...]grandchildren
of Standard.

****************************************************************


Questions? Ask the ACAA Technical Agent