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

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

!standard 13.13.2(38/3)          14-08-11 AI05-0106-1/02
!class binding interpretation 14-05-14
!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-0106-1 are adopted. Note that 13.13.2(38/3) is split into two paragraphs, and we only modify the first.]
[IMPORTANT: I've only split the AI as directed; I made no attempt to "rationalize" the AI as Tucker volunteered to do. That may change the wording and certainly will change the discussion.]
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 attributes can 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 attributes can be specified for a tagged type T using the name of the stream attribute followed by 'Class; such class-wide aspects are not inherited for other descendants of T.}
AARM Reason: We need 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 split paragraph below.]
!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. So we add an appropriate definition so that there can be no doubt about the intent.
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, so the wording says explicitly that this is not the case.
!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 attributes can be specified using an aspect_specification on any type_declaration other than an incomplete_type_declaration, with the aspect name being the corresponding attribute name.] Each of the class-wide stream attributes can be specified for a tagged type T using the name of the stream attribute followed by 'Class; such class-wide aspects are not inherited for other descendants of T.
!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.

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

Questions? Ask the ACAA Technical Agent