Version 1.2 of ai05s/ai05-0042-1.txt

Unformatted version of ai05s/ai05-0042-1.txt version 1.2
Other versions for file ai05s/ai05-0042-1.txt

!standard 3.9.3(6/2)          07-10-25 AI05-0042-1/01
!standard 12.3(18)
!class binding interpretation 07-03-27
!status work item 07-03-27
!status received 07-01-22
!priority Medium
!difficulty Medium
!qualifier Omission
!subject Overriding versus implemented-by
!summary
A subprogram that is implemented by an entry or by a protected subprogram is effectively overridden by an implict subprogram which calls the entry or protected subprogram.
!question
As part of the introduction of synchronized interfaces, we added the notion of an operation being "implemented by" an entry or a protected operation. This is a concept which is related to overriding, but has subtle differences.
Unfortunately, there appears to be quite a few places where the RM says "overridden" and where it should probably have said "overridden or implemented by". Here is an example:
package Pkg1 is type Ifc is protected interface; procedure P1 (X : in out Ifc; Y : Integer) is abstract; procedure P2 (X : in out Ifc; Y : Integer) is abstract; end Pkg1;
package Pkg2 is protected type Prot is new Pkg1.Ifc with procedure P1 (Y : Integer); entry P2 (Y : Integer); end Prot; end Pkg2;
Presumably this code should be legal, but there is no doubt that it violates 3.9.3(6/2), since the operations P1 and P2 inherited by Prot are not overridden.
Similarly, 12.3(18) describes how overriding happens in an instance, with interesting differences between the visible part and the private part. Presumably there should be similar words for "implemented by", but there are not.
!recommendation
(See Summary.)
!wording
Add after 9.1(9.2/2):
A subprogram implemented by a task entry is also overridden by an implicit, nonabstract subprogram having a subtype conformant profile. [At execution time, the effect of this implicit subprogram is to call the task entry.]
AARM: This rule is needed so that a subprogram implemented by an entry is considered to be overridden for the purpose of the other rules of the language. Without it, it would for instance be illegal for an abstract subprogram to be implemented by an entry, because the abstract subprogram would not be overridden. The rules in 9.1(9.6/2-9.8/2) and 9.4(11.5/2-11.7/2) ensure that there is no conflict between the implicit overriding subprogram and a user-defined overriding subprogram.
Add after 9.4(11.1/2):
A subprogram implemented by a protected subprogram or entry is also overridden by an implicit, nonabstract subprogram having a subtype conformant profile. [At execution time, the effect of this implicit subprogram is to call the protected subprogram or entry.]
!discussion
One possible fix would be to change "overridden" by "overridden or implemented by" everywhere. But there are 24 occurrences of "overridden" in the RM, and the occurrences of "overriding" would have to be checked too. That's unappealing. It seems more straightforward to reify the model that we have had in mind all along anyway, namely that there is an implicit override that acts as a wrapper to call the protected subprogram or entry.
--!corrigendum 10.1.2(20/2)
!ACATS test
A C test should be written to ensure that a code fragment like the one in the
!question is actually accepted by implementations.
!appendix

From: Pascal Leroy
Date: Monday, January 22, 2007 10:30 PM

As part of the introduction of synchronized interfaces, we added the
notion of an operation being "implemented by" an entry or a protected
operation. This is a concept which is related to overriding, but has
subtle differences.

Unfortunately, there appears to be quite a few places where the RM says
"overridden" and where it should probably have said "overridden or
implemented by".  Here is an example:

    package Pkg1 is
        type Ifc is protected interface;
        procedure P1 (X : in out Ifc; Y : Integer) is abstract;
        procedure P2 (X : in out Ifc; Y : Integer) is abstract;
    end Pkg1;

    package Pkg2 is
        protected type Prot is new Pkg1.Ifc with
            procedure P1 (Y : Integer);
            entry P2 (Y : Integer);
        end Prot;
    end Pkg2;

Presumably this code should be legal, but there is no doubt that it
violates 3.9.3(6/2), since the operations P1 and P2 inherited by Prot are
not overridden.

Similarly, 12.3(18) describes how overriding happens in an instance, with
interesting differences between the visible part and the private part.
Presumably there should be similar words for "implemented by", but these
words are missing.

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

From: Tucker Taft
Date: Monday, January 22, 2007 10:37 PM

I would prefer to solve this by saying that "under
such-and-such circumstances, the inherited operation
is overridden by an implicit operation that invokes
the corresponding entry or protected operation."
This way we can continue to say overridden and not
get into trouble.  Having to spread the "implemented by"
wording all over the place seems undesirable.

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


Questions? Ask the ACAA Technical Agent