Version 1.1 of ais/ai-00129.txt

Unformatted version of ais/ai-00129.txt version 1.1
Other versions for file ais/ai-00129.txt

!standard 07.03 (10)          97-11-14 AI95-00129/01
!class confirmation 96-04-04
!status ARG Approved 11-0-1 97-11-14
!status work item 96-04-04
!status received 96-04-04
!priority Low
!difficulty Medium
!subject Discriminant Inheritance for Private Extensions
!summary 96-04-04
If a private extension inherits unknown discriminants, the corresponding full view may inherit known discriminants, and may be constrained or unconstrained.
!question 96-04-04
Consider the following code fragment. Is the constraint in the full declaration of type Child.T legal? (Yes.)
package Parent is type T (<>) is tagged private; private type T (D : Integer) is tagged null record; end Parent;
package Parent.Child is type T is new Parent.T with private; private type T is new Parent.T (D => 3) with null record; -- Legal? (Yes.) end Parent.Child;
The issue has to do with 7.3(10) which says: "if a private extension inherits known discriminants from the ancestor subtype, then the full view shall also inherit its discriminants from the ancestor subtype, and the parent subtype of the full view shall be constrained iff the ancestor subtype is constrained."
Does the private extension Child.T inherit known discriminants from the ancestor subtype?
!response 96-04-04
The private extension Child.T inherits unknown discriminants (not known discriminants) from the partial view of Parent.T (which is the only view of Parent.T visible to the private extension). Thus, 7.3(10) does not apply. The example is legal.
!appendix

!section 7.3(10)
!subject When does a private extension inherit known discriminants from its ancestor?
!reference 96-5451.c Pascal Leroy 96-3-27>>
!reference RM95-7.3(10)
!from Pascal Leroy 96-03-27
!discussion

Consider the following code fragment.  Is the constraint in the full
declaration of type Child.T legal?

     package Parent is
         type T (<>) is tagged private;
     private
         type T (D : Integer) is tagged null record;
     end Parent;

     package Parent.Child is
         type T is new Parent.T with private;
     private
         type T is new Parent.T (D => 3) with null record; -- legal?
     end Parent.Child;

The issue has to do with RM95 7.3(10) which says: "if a private extension
inherits known discriminants from the ancestor subtype, then the full view
shall also inherit its discriminants from the ancestor subtype, and the parent
subtype of the full view shall be constrained iff the ancestor subtype is
constrained."

Does the private extension Child.T inherit known discriminants from the
ancestor subtype?  The answer seems to depend on whether we ask this question
on the partial view or on the full view.

If the answer to this question is yes, then 7.3(10) applies, and the
constraint is illegal. If the answer is no, then 7.3(10) is irrelevant and the
constraint is legal.

_____________________________________________________________________
Pascal Leroy                                    +33.1.30.12.09.68
pleroy@rational.com                             +33.1.30.12.09.66 FAX

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

!section 7.3(10)
!subject When does a private extension inherit known discriminants from its ancestor?
!reference RM95-7.3(10)
!reference 96-5451.c Pascal Leroy 96-3-27
!from Gary Dismukes 96-03-28
!reference 96-5453.a Gary Dismukes 96-3-28>>
!discussion

> Consider the following code fragment.  Is the constraint in the full
> declaration of type Child.T legal?

I believe it's legal.

>      package Parent is
>          type T (<>) is tagged private;
>      private
>          type T (D : Integer) is tagged null record;
>      end Parent;
> 
>      package Parent.Child is
>          type T is new Parent.T with private;
>      private
>          type T is new Parent.T (D => 3) with null record; -- legal?
>      end Parent.Child;
> 
> The issue has to do with RM95 7.3(10) which says: "if a private extension
> inherits known discriminants from the ancestor subtype, then the full view
> shall also inherit its discriminants from the ancestor subtype, and the parent
> subtype of the full view shall be constrained iff the ancestor subtype is
> constrained."
> 
> Does the private extension Child.T inherit known discriminants from the
> ancestor subtype?  The answer seems to depend on whether we ask this question
> on the partial view or on the full view.

The private extension inherits unknown discriminants from the partial
view of Parent.T (which is the only view of Parent.T visible to the
private extension).

> If the answer to this question is yes, then 7.3(10) applies, and the
> constraint is illegal. If the answer is no, then 7.3(10) is irrelevant and the
> constraint is legal.

The rule doesn't apply as far as I can see since the private extension
doesn't inherit known discriminants.

-- Gary Dismukes

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

Questions? Ask the ACAA Technical Agent