Version 1.3 of ais/ai-00377.txt

Unformatted version of ais/ai-00377.txt version 1.3
Other versions for file ais/ai-00377.txt

!standard 08.03(26/1)          04-10-04 AI95-00377/02
!class binding interpretation 04-04-20
!status work item 04-08-31
!status received 04-03-23
!priority Low
!difficulty Medium
!subject Naming of generic child packages
!summary
If a library unit generic and a library unit instance thereof have child units with the same name, then the explicitly declared child of the instance and the implicit declaration corresponding to the child of the generic hide each other.
!question
If a library unit generic and a library unit instance thereof have child units with the same name (see the example), then it would seem that the instance declares nonoverloadable homographs. Was this intended? (No.)
!recommendation
(See summary.)
!wording
Append to end of 10.1.1(19):
Furthermore, if the instance is a library package, then this declaration is not visible within the scope of a with_clause that mentions a child unit of the instance which is a homograph of this declaration.
Append after 10.1.2(7):
A child unit of a library unit instance of a generic package is not visible within the scope of a with_clause that mentions a child unit of the generic which is a homograph of the child unit of the instance.
!discussion
This scenario never occurs in practice. The language needs to be well-defined and a solution should be chosen which is easy to specify and to implement, but users really don't care about this one at all.
We do not want to allow a view of an instance which declares non-overloadable homographs (see, for example, the first sentence of 8.3(26/1)). It seems at least possible that this might requires a bunch of special-case visibility rules, and that is reason enough to abandon this approach.
Another approach would be to prefer one of the declarations over the other, but hiding both declarations seems cleaner.
!example
generic package G1 is end G1;
generic package G1.G2 is end G1.G2;
with G1; package I1 is new G1;
package Some_Package is end Some_Package;
with Some_Package; package I1.G2 renames Some_Package;
with G1.G2; with I1.G2; package Q1 renames I1.G2; -- legal? (no)
with G1.G2; with I1.G2; package Q2 is new I1.G2; -- legal? (no)
with G1.G2; with I1.G2; with System; procedure Q3 (X : System.Address := I1.G2'Address); -- legal? (no)
--!corrigendum
!ACATS test
A B-Test should be constructed out of the example of this AI.
!appendix

From: Stephen W. Baird
Sent: Tuesday, March 23, 2004  12:34 AM

Consider the following example:

    generic
    package G1 is
    end G1;

    generic
    package G1.G2 is
    end G1.G2;

    with G1;
    package I1 is new G1;

    with G1;
    package I1.G2 renames Standard;

    with G1.G2;
    with I1.G2;
    package Q1 renames I1.G2; -- legal?

    with G1.G2;
    with I1.G2;
    package Q2 is new I1.G2; -- legal?

    with G1.G2;
    with I1.G2;
    with System;
    procedure Q3 (X : System.Address := I1.G2'Address);  -- legal?

Should Q1, Q2, and Q3 be rejected?

It seems to me that they should, but RM justification for this position is
not obvious.

In particular, the two "I1.G2" declarations, one a generic package and one
a non-generic package rename, do not appear to be hidden from all
visibility at the points where the name is used.

One might argue that withing  both G1.G2 and I1.G2 implicitly results in a
view of package I1 which violates the first sentence of 8.3(26/1), but
that seems like a stretch.

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


Questions? Ask the ACAA Technical Agent