Version 1.5 of ai12s/ai12-0050-1.txt

Unformatted version of ai12s/ai12-0050-1.txt version 1.5
Other versions for file ai12s/ai12-0050-1.txt

!standard 6.3.1(20)          13-07-17 AI12-0050-1/04
!standard 6.3.1(21)
!class binding interpretation 12-12-04
!status Amendment 202x 13-07-17
!status WG9 Approved 13-11-15
!status ARG Approved 7-0-0 13-06-16
!status work item 12-12-04
!status received 12-08-29
!priority Low
!difficulty Medium
!subject Conformance of quantified expressions
!summary
Quantified expressions fully conform if the loop parameter in each have the same identifier, and the range, iterable_name, or iterator_name fully conforms.
!question
Consider the following example:
procedure Conform (S : String) is procedure Foo (X : Boolean := (for all Index in S'range => (S (Index) /= '?'))); procedure Foo (X : Boolean := (for all Index in S'range => (S (Index) /= '?'))) is -- Legal?? begin null; end Foo; begin Foo; end Conform;
Consider the two uses of the identifier Index. The first refers to the loop parameter declared in the first quantified expression; the second refers to the loop parameter declared in the second quantified expression. These are not the same, so the two default expressions are not fully conformant by 6.3.1(21).
This doesn't make any sense, is a fix needed? (Yes.)
!recommendation
(See summary.)
!wording
Add after 6.3.1(20):
* corresponding defining_identifiers occurring within the two expressions are the same; and
Modify 6.3.1(21) as follows:
* each direct_name, character_literal, and selector_name that is not part of the prefix of an expanded name in one denotes the same declaration as the corresponding direct_name, character_literal, or selector_name in the other{, or they denote corresponding declarations occurring within the two expressions}; and
!discussion
We talk about corresponding declarations because of the possibility of iterator_specifications (and parameterized_array_component_specifications -- see AI12-0061-1) occurring within default expressions.
We have to mention the defining identifiers being the same, so that
(for all I1 in S'Range => (S (I1) /= '?')))
does not fully conform with
(for all I2 in S'Range => (S (I2) /= '?'))) is -- Legal?? (No.)
!corrigendum 6.3.1(20)
Insert after the paragraph:
the new paragraph:
!corrigendum 6.3.1(21)
Replace the paragraph:
by:
!ASIS
No ASIS effect.
!ACATS test
An ACATS B-Test should be created to test conformance rules of quantified expressions.
!appendix

From: Steve Baird
Sent: Wednesday, August 29, 2012  11:25 AM

RM 6.3.1 (21) says (as part of defining what it means for two expressions to be "fully conformant"):
     - each direct_name, character_literal, and selector_name that is not
       part of the prefix of an expanded name in one denotes the same
       declaration as the corresponding direct_name, character_literal,
       or selector_name in the other;

Consider the following example:

    procedure Conform (S : String) is
      procedure Foo (X : Boolean :=
        (for all Index in S'Range => (S (Index) /= '?')));
      procedure Foo (X : Boolean :=
        (for all Index in S'Range => (S (Index) /= '?'))) is
        begin null; end; -- legal?
    begin Foo; end;

Consider the two uses of the identifier Index. The first refers to the object
declared in the first quantified expression; the second refers to the object
declared in the second quantified expression. These are not the same, so the two
default expressions are not fully conformant.

This means that the example is illegal, and that no legal completion for the
declaration of Foo is possible. IMHO, this is not what we want.

Tuck suggested (after being given about 30 seconds to consider the problem) that
perhaps "the same" should be replaced with something like "the same or a
corresponding". In choosing wording to address this problem, we should also keep
in mind the variation obtained by replacing the last two occurrences of "Index"
with some other identifier, say "Xyzzy":

      procedure Foo (X : Boolean :=
        (for all Index in S'Range => (S (Index) /= '?')));
      procedure Foo (X : Boolean :=
        (for all Xyzzy in S'Range => (S (Xyzzy) /= '?'))) is
        begin null; end;

Do we want this second version to be legal? I don't think the handling of this
case matters much, but it should be well defined.

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

From: Randy Brukardt
Sent: Wednesday, August 29, 2012  11:40 PM

What do we do for anonymous access types? They have a similar problem, which I
presume we solved somehow.

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

From: Jean-Pierre Rosen
Sent: Thursday, August 30, 2012  1:58 AM

> This means that the example is illegal, and that no legal completion
> for the declaration of Foo is possible. IMHO, this is not what we
> want.

My first reaction is that it is a typical example where the Dewar's principle
applies. We know damn well that this has to be legal!

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

From: Robert Dewar
Sent: Thursday, August 30, 2012  3:08 AM

> My first reaction is that it is a typical example where the Dewar's
> principle applies. We know damn well that this has to be legal!

Defnitely! So it is just some language lawyer stuff needed here that wont affect
anything.

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

From: Tucker Taft
Sent: Thursday, August 30, 2012  2:36 AM

> Tuck suggested (after being given about 30 seconds to consider the
> problem) that perhaps "the same" should be replaced with something
> like "the same or a corresponding". In choosing wording to address
> this problem, we should also keep in mind the variation obtained by
> replacing the last two occurrences of "Index" with some other
> identifier, say "Xyzzy":
>
> procedure Foo (X : Boolean :=
> (for all Index in S'Range => (S (Index) /= '?'))); procedure Foo (X :
> Boolean := (for all Xyzzy in S'Range => (S (Xyzzy) /= '?'))) is begin
> null; end;
>
> Do we want this second version to be legal? I don't think the handling
> of this case matters much, but it should be well defined.

No, we don't want this to be legal in my view.
"Full conformance" implies very, very similar.
For the declarations to be conforming, they should use the same
defining_identifier, IMHO.

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

From: Robert Dewar
Sent: Thursday, August 30, 2012  3:12 AM

The second case with different names should be illegal.

Always remember that the underlying principle here is that the two expressions
should be lexically identical. Well that doesn''t quite work, so we modify it a
bit, but only as much as is necessary.

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


Questions? Ask the ACAA Technical Agent