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

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

!standard H.7(7/5)          21-06-07 AI12-0431-1/03
!class Amendment 21-05-28
!status Amendment 1-2012 21-06-07
!status WG9 Approved 22-06-22
!status ARG Approved 12-0-2 21-06-03
!status work item 21-05-28
!status received 21-05-28
!priority Low
!difficulty Easy
!subject Confirming predicate shouldn't change semantics
!summary
Exclude confirming predicates from H.7(7/5).
!problem
H.7(7/5) is a rule that seems to be partially determined by the absence or presence of a subtype predicate. That sort of rule creates problems because our usual rule (see 13.1(1.a.1/3)) is that a confirming aspect specification has no effect. So for example, specifying a predicate to be statically True should normally have no effect.
!proposal
(See Summary.)
!wording
Modify H.7(7/5):
... if not specified for a nonderived elementary first subtype (or scalar base subtype), the aspect defaults to null in the absence of a predicate {(or when the predicate is statically True)}, and to that of the enclosing library unit otherwise. If not specified for a nonfirst subtype S, the Global aspect defaults to that of the subtype identified in the subtype_indication defining S.
!discussion
This is only a partial solution to the problem posed: it does not fix the issue issue for confirming predicates of a subtype_declaration. That would be more complex as one would need some sort of expression conformance to do that.
!corrigendum H.7(0)
Insert new clause:
See the conflict file for the changes.
!ASIS
No ASIS effect.
!ACATS test
Might want an ACATS test to check that this minor modification is followed, but it seems to be a fairly low priority.
!appendix

From WG 9 review item #67, Tucker Taft

H.7(7/5): We have a rule that seems to be partially determined by the absence 
or presence of a subtype predicate. That sort of rule creates problems because
our usual rule (see 13.1(1.a.1/3)) is that a confirming aspect specification 
has no effect. So for example, specifying a predicate to be statically True 
should normally have no effect.

Here is the current wording for the rule in H.7(7/5):

    ... if not specified for a nonderived elementary first subtype (or scalar 
    base subtype), the aspect defaults to null in the absence of a predicate, 
    and to that of the enclosing library unit otherwise. If not specified for 
    a nonfirst subtype S, the Global aspect defaults to that of the subtype 
    identified in the subtype_indication defining S.

To avoid violating the principle that a confirming aspect specification has no
effect, this should perhaps say:

    ... if not specified for a nonderived elementary first subtype (or scalar 
    base subtype), the aspect defaults to null in the absence of a predicate 
    {(or when the predicate is statically True)}, and to that of the enclosing
    library unit otherwise. If not specified for a nonfirst subtype S, the
    Global aspect defaults to that of the subtype identified in the
    subtype_indication defining S.

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

From WG 9 review item #67, Randy Brukardt

This proposal only fixes this problem for a type declaration. I'd expect that 
specifying a confirming predicate for such a declaration to be extremely rare 
as there is no reason to do so and it would be confusing to readers:

           type Foo is range 0 .. 99 
              with Static_Predicate => True; -- Why write a predicate here that can't fail??

OTOH, it does nothing for the more likely confirming predicate on a 
subtype_declaration. If the subtype_declaration is in a different unit than 
the ancestor subtype, that could matter. That is, something like:

    subtype Even is Integer with Dynamic_Predicate => Is_Even(Even);

...
    subtype Local_Even is P.Even with Dynamic_Predicate => P.Is_Even(Even);

It's clear that a rule for this second case would be fairly complex, requiring 
some sort of conformance. That's probably not worth it.

Thus, I don't see much reason to complicate the rules to fix only the simple
(and unlikely) case of confirming aspects and not more complex cases.

I put this into a separate AI (AI12-0431-1) so the ARG can discuss the issue 
as a group.

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

Questions? Ask the ACAA Technical Agent