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

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

!standard 13.1.1(18.3/5)          17-10-11 AI12-0211-1/03
!standard 13.1.1(18.4/4)
!class binding interpretation 16-12-20
!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
!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.
!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