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

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

!standard 13.1.1(18.3/5)          16-12-20 AI12-0211-1/01
!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
!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 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.{ In the case of an aspect whose value is a static expression, the specified expression shall match the inherited aspect by having the same value.}
[Editor's note: we use "match" in the new wording and in the existing 13.1.1(18.4/4), but we never say what it means for a static-valued aspect. We really ought to say what it means for an expression-valued aspect (full conformance), too, but we don't need that yet.]
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 each ancestor shall match that 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