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

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

!standard 13.1.1(18.3/5)          17-06-17 AI12-0211-1/02
!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(18.2/3):
An aspect_specification or representation item that specifies a representation aspect that would have been chosen in the absence of the aspect_specification or representation item is said to be confirming. {In the case of an aspect whose value is a name, this means that, the specified name shall be the same as the inherited aspect and therefore denote the same declarations as would the inherited name. In the case of an aspect whose value is a static expression, the specified expression shall have the same static value as the inherited aspect.} The aspect value specified in this case is said to be a confirming representation aspect value. Other values of the aspect are said to be nonconfirming, as are the aspect_specifications and representation items that specified them.
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 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 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 for those of the 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.

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

Questions? Ask the ACAA Technical Agent