Version 1.5 of ai12s/ai12-0211-1.txt

Unformatted version of ai12s/ai12-0211-1.txt version 1.5
Other versions for file ai12s/ai12-0211-1.txt

!standard 13.1.1(18.3/5)          17-11-17 AI12-0211-1/04
!standard 13.1.1(18.4/4)
!class binding interpretation 16-12-20
!status Amendment 1-2012 17-11-17
!status ARG Approved 6-0-2 17-10-13
!status work item 16-12-20
!status received 16-10-02
!priority Low
!difficulty Easy
!qualifier Omission
!subject Interface types and inherited nonoverridable aspects
!summary
A nonoverridable aspect of type T has to inherit the same value from all ancestors of type T; otherwise T is illegal.
!question
Is the following example legal? (No.)
If it was legal then what is the Constant_Indexing aspect of type T?
with Text_IO; use Text_IO; procedure Nonoverridable_Test is package Pkg is type Ifc1 is interface with Constant_Indexing => F1; function F1 (X : Ifc1; Y : Natural) return Character is abstract;
type Ifc2 is interface with Constant_Indexing => F2; function F2 (X : Ifc2; Y : Natural) return Character is abstract;
type T is new Ifc1 and Ifc2 with record S1, S2 : String (1 .. 123); end record;
overriding function F1 (X : T; Y : Natural) return Character is (X.S1 (Y));
overriding function F2 (X : T; Y : Natural) return Character is (X.S2 (Y)); end Pkg;
X : Pkg.T := (S1 => (others => '1'), S2 => (others => '2'));
C : Character := X (100); begin Put_Line (C & ""); end;
!recommendation
(See Summary.)
!wording
Modify 13.1.1(18.3/5): [As modified by AI12-0206-1]
If a nonoverridable aspect is directly specified for a type T, then any explicit specification of that aspect for any [other] descendant of T {(other than T itself)} shall be confirming. In the case of an aspect whose value is a name, this means that the specified name shall {}match{} the inherited aspect [and therefore] {in the sense that it shall} denote the same declarations as would the inherited name.
Add after 13.1.1(18.4/4):
If a type inherits a nonoverridable aspect from multiple ancestors, the value of the aspect inherited from any given ancestor shall be confirming of the values inherited from all other ancestors.
AARM Reason: If more than one progenitor of a type T specifies a nonoverridable aspect, they all have to specify the same primitive of T. Otherwise, we'd have two different values for the aspect.
!discussion
Obviously, one cannot have a type where a single aspect has two different values. We have to craft a rule to make this illegal.
!corrigendum 13.1.1(18.3/4)
Replace the paragraph:
If a nonoverridable aspect is directly specified for a type T, then any explicit specification of that aspect for any other descendant of T shall be confirming; that is, the specified name shall match the inherited aspect, meaning that the specified name shall denote the same declarations as would the inherited name.
by:
If a nonoverridable aspect is directly specified for a type T, then any explicit specification of that aspect for any descendant of T (other than T itself) shall be confirming. In the case of an aspect whose value is a name, this means that the specified name shall match the inherited aspect in the sense that it shall denote the same declarations as would the inherited name.
!corrigendum 13.1.1(18.4/4)
Insert after the paragraph:
If a full type has a partial view, and a given nonoverridable aspect is allowed for both the full view and the partial view, then the given aspect for the partial view and the full view shall be the same: the aspect shall be directly specified only on the partial view; if the full type inherits the aspect, then a matching definition shall be specified (directly or by inheritance) for the partial view.
the new paragraph:
If a type inherits a nonoverridable aspect from multiple ancestors, the value of the aspect inherited from any given ancestor shall be confirming of the values inherited from all other ancestors.
!ASIS
No ASIS effect.
!ACATS test
An ACATS B-test is needed to check this rule.
!appendix

From: Steve Baird
Sent: Sunday, October 2, 2016  6:23 PM

I think we need a rule that if a nonoverridable aspect is inherited from more
than one parent or progenitor type, then the inherited aspects have to agree.

Is the following example legal? I don't think it should be, but I don't see
what rule prohibits it. If it is legal then what is the Constant_Indexing
aspect of type T?

  with Text_IO; use Text_IO;
  procedure Nonoverridable_Test is
     package Pkg is
       type Ifc1 is Interface with Constant_Indexing => F1;
       function F1 (X : Ifc1; Y : Natural) return Character is abstract;

       type Ifc2 is Interface with Constant_Indexing => F2;
       function F2 (X : Ifc2; Y : Natural) return Character is abstract;

       type T is new Ifc1 and Ifc2
         with record S1, S2 : String (1 .. 123); end record;

       overriding
       function F1 (X : T; Y : Natural) return Character is (X.S1 (Y));

       overriding
       function F2 (X : T; Y : Natural) return Character is (X.S2 (Y));
     end Pkg;

    X : Pkg.T := (S1 => (others => '1'), S2 => (others => '2'));

    C : Character := X (100);
  begin
    Put_Line (C & "");
  end;

Opinions?

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

From: Tucker Taft
Sent: Sunday, October 2, 2016  7:07 PM

Agreed with your suggestion of making such a situation illegal.

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

From: Tucker Taft
Sent: Wednesday, October 11, 2017  4:44 PM

Here is a modest update to AI12-0211, to try to untangle some of the wording
of the first attempt. [This is version /03 - Editor.]

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

Questions? Ask the ACAA Technical Agent