Version 1.4 of ais/ai-00377.txt
!standard 08.03(26/1) 04-11-30 AI95-00377/03
!class binding interpretation 04-04-20
!status Amendment 200Y 04-11-30
!status ARG Approved 6-0-1 04-11-21
!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, and both are mentioned in with_clauses, the
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
In 8.3(26/1), change:
Similarly, the context_clause for a {compilation unit}[subunit] is illegal if
it mentions (in a with_clause) some library unit, and there is a homograph of
the library unit that is visible at the place of
the {compilation unit}[corresponding stub], and the homograph and the
mentioned library unit are both declared immediately within the same
declarative region.
!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,
or to hide both declarations, but making the offending with_clause illegal
is cleaner and corresponds to what is done for subunits.
!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; --
with G1.G2;
with I1.G2;
package Q2 is new I1.G2; --
with G1.G2;
with I1.G2;
with System;
procedure Q3 (X : System.Address := I1.G2'Address); --
In each of these cases, the with of I1.G2 is illegal.
!corrigendum 8.3(26/1)
Replace the paragraph:
A non-overridable declaration is illegal if there is a homograph occurring
immediately within the same declarative region that is visible at the place of
the declaration, and is not hidden from all visibility by the non-overridable
declaration. In addition, a type extension is illegal if somewhere within its
immediate scope it has two visible components with the same name. Similarly,
the context_clause for a subunit is illegal if it mentions (in a
with_clause) some library unit, and there is a homograph of the library
unit that is visible at the place of the corresponding stub, and the homograph
and the mentioned library unit are both declared immediately within the same
declarative region. These rules also apply to dispatching operations declared
in the visible part of an instance of a generic unit. However, they do not
apply to other overloadable declarations in an instance; such declarations may
have type conformant profiles in the instance, so long as the corresponding
declarations in the generic were not type conformant.
by:
A non-overridable declaration is illegal if there is a homograph occurring
immediately within the same declarative region that is visible at the place of
the declaration, and is not hidden from all visibility by the non-overridable
declaration. In addition, a type extension is illegal if somewhere within its
immediate scope it has two visible components with the same name. Similarly,
the context_clause for a compilation unit is illegal if it mentions (in a
with_clause) some library unit, and there is a homograph of the library
unit that is visible at the place of the compilation unit, and the homograph
and the mentioned library unit are both declared immediately within the same
declarative region. These rules also apply to dispatching operations declared
in the visible part of an instance of a generic unit. However, they do not
apply to other overloadable declarations in an instance; such declarations may
have type conformant profiles in the instance, so long as the corresponding
declarations in the generic were not type conformant.
!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