Version 1.8 of ai12s/ai12-0106-1.txt

Unformatted version of ai12s/ai12-0106-1.txt version 1.8
Other versions for file ai12s/ai12-0106-1.txt

!standard 13.1.1(28/3)          15-01-19 AI12-0106-1/05
!standard 13.13.2(38/3)
!class binding interpretation 14-05-14
!status Corrigendum 1-2012 14-11-13
!status WG9 Approved 15-06-26
!status ARG Approved 7-0-1 14-10-18
!status work item 14-05-14
!status received 14-04-25
!priority Medium
!difficulty Easy
!qualifier Omission
!subject Write'Class aspect
!summary
Class-wide stream attributes can be specified with the syntax <aspect>'Class, but they are never inherited.
!question
ACATS 4.0 test BDD2005 contains a number of cases like:
type My_Tagged_4 is abstract tagged null record with Write'Class => Good_Write3;-- OK.
The test assumes this is the notation for specifying class-wide stream aspects.
However, an argument can be made that these aspects cannot be specified with an aspect_specification since they need to be specified on the type T'Class, and that type never has an explicit declaration.
Another argument can be made that they can be specified, but their name is "Class'Write". That can be refuted by the fact that there is no such syntax defined for aspect_specifications.
So, do we want to be able to specify Write'Class as suggested by the new ACATS test? (Yes.)
!recommendation
(See Summary.)
!wording
[Editor's note: The below wording assumes that the changes of AI12-0121-1 are adopted. Note that 13.13.2(38/3) is split into two paragraphs, and we only modify the first.]
Modify 13.1.1(28/3):
If the aspect_mark includes 'Class {(a /class-wide aspect/)}, then {, unless specified otherwise for a particular class-wide aspect}:
Modify 13.13.2(38/3):
The stream-oriented attributes may be specified for any type via an attribute_definition_clause. {Redundant[Alternatively, each of the specific stream-oriented attributes may be specified using an aspect_specification on any type_declaration, with the aspect name being the corresponding attribute name.] Each of the class-wide stream-oriented attributes may be specified using an aspect_specification for a tagged type T using the name of the stream-oriented attribute followed by 'Class; such class-wide aspects do not apply to other descendants of T.}
AARM Reason: We need the last part of the last sentence to override the blanket rule given in 13.1.1 that aspect'Class applies to the type and all descendants.
[Yet another Editor's note: Add Aspect Descriptions for Read'Class, Write'Class, and so on after the existing ones. Probably move the existing ones up below the above paragraph, the other existing AARM notes will follow the second half of the split paragraph.]
!discussion
We want to be able to use aspect_specifications in as many cases as possible, so we want some way to specify the class-wide stream aspects. Moreover, both the syntax of aspect_specifications and consistency argue that the form of such names is <aspect>'Class. Finally, aspect specifications are associated with explicit declarations only, and T'Class is declared implicitly. So we propose that the attribute XYZ of T'Class can be specified by specifying the XYZ'Class aspect of T.
Of course, we want this for all four stream attributes.
Note that 13.1.1(29/3) says that a class-wide aspect of a type applies to all descendants of the type. We don't want that to happen in this case (as it doesn't happen for an attribute_definition_clause, and we surely don't want these to act different), so we adjust the wording in 13.1.1(28/3) to say "unless specified otherwise..." and then in 13.13.2 indicate that it doesn't apply to the class-wide stream aspects.
!corrigendum 13.1.1(28/3)
Replace the paragraph:
If the aspect_mark includes 'Class, then:
by:
If the aspect_mark includes 'Class (a class-wide aspect), then, unless specified otherwise for a particular class-wide aspect:
!corrigendum 13.13.2(38/3)
Replace the paragraph:
The stream-oriented attributes may be specified for any type via an attribute_definition_clause. The subprogram name given in such a clause shall statically denote a subprogram that is not an abstract subprogram. Furthermore, if a stream-oriented attribute is specified for an interface type by an attribute_definition_clause, the subprogram name given in the clause shall statically denote a null procedure.
by:
The stream-oriented attributes may be specified for any type via an attribute_definition_clause. Alternatively, each of the specific stream-oriented attributes may be specified using an aspect_specification on any type_declaration, with the aspect name being the corresponding attribute name. Each of the class-wide stream-oriented attributes may be specified using an aspect_specification for a tagged type T using the name of the stream-oriented attribute followed by 'Class; such class-wide aspects do not apply to other descendants of T.
The subprogram name given in such an attribute_definition_clause or aspect_specification shall statically denote a subprogram that is not an abstract subprogram. Furthermore, if a specific stream-oriented attribute is specified for an interface type, the subprogram name given in the attribute_definition_clause or aspect_specification shall statically denote a null procedure.
!ASIS
No ASIS effect.
!ACATS test
ACATS test BDD2005 already assumes this notation can be used. An ACATS C-Test should be constructed to check that these aspects can be overridden this way.
!appendix

From: Randy Brukardt
Sent: Friday, April 25, 2014  5:22 PM

I discussed this privately a few weeks ago, but I've just noticed another issue
so that discussion needs to be revisited - and brought to the whole group.

One of the new ACATS tests contains a number of cases like:

    type My_Tagged_4 is abstract tagged null record
       with Write'Class => Good_Write3;-- OK.

I presumed that this was the aspect notation for specifying
My_Tagged_4'Class'Write.

Steve Baird objected, saying that the name of the aspect in that case is either
Write (specified on T'Class, which is of course impossible) or Class'Write
(which is not allowed by the syntax of aspect specifications for
language-defined aspects). He seemed to agree that we wanted the above but
didn't think the language rules allowed it as written.

The rest of the people in the conversation thought that at a minimum the Dewar
rule applied (we want to be able to specify as much as possible using aspect
notation, the syntax of aspect specifications only allows id'Class, ergo this
must be right whether or not the language formally allows it). Ed (or someone)
fixed GNAT to allow the above and the conversation ended.

I've now noticed another problem with the above which makes me lean a bit more
to Steve's position. In particular, 13.1.1(29/3) says that a class-wide aspect
of a type applies to all descendants of the type. We don't want that to happen
in this case (I think), so we need some wording to override this rule.

Thus I think we need a sentence like "S'Class'Write can be specified for a
tagged type T using the aspect Write'Class; this aspect is not inherited for
other descendants of T." after 13.13.2(13). And similarly for the other 3
class-wide attributes.

An alternative would be to simply "confirm" (really a ramification) that these
attributes cannot be specified via an aspect specification, since there is no
declaration for S'Class. I'm not a fan of this approach (I'd rather everything
could be specified with an aspect specification, so that a programmer could
forget about attribute_definition_clauses and representation pragmas if they
wish), but there is some logic to it. If we go this way, I need to fix the ACATS
test ASAP.

Note, of course, that the "only Ada 2012 compiler" as Robert likes to say does
support this notation -- but that is a fairly recent change so it's not very
likely anyone is depending upon it.

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

From: Tucker Taft
Sent: Monday, April 28, 2014  9:00 AM

For what it is worth, I find "with Write'Class =>" preferable to "with
Class'Write =>" but I understand Steve's point.  "with Class'Write" just seems a
bit too weird to me, and the connection with Pre'Class, Post'Class, etc., seems
natural, even if the inheritance rules are different.

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

From: Tucker Taft
Sent: Monday, October 13, 2014  2:38 PM

Here is a very modest revision of AI12-0106, indicating that to specify the XYZ
*attribute* of T'Class, you do so by specifying the XYZ'Class *aspect* of T.
[This is version /03 of the AI - Editor.]

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

Questions? Ask the ACAA Technical Agent