Version 1.1 of ai12s/ai12-0213-1.txt

Unformatted version of ai12s/ai12-0213-1.txt version 1.1
Other versions for file ai12s/ai12-0213-1.txt

!standard 3.8(3)          16-12-28 AI12-0213-1/01
!standard 13.5.1(2)
!class Amendment 16-12-28
!status work item 16-12-28
!status received 16-10-06
!priority Very_Low
!difficulty Easy
!subject Unify record syntax
*** Missing.
Ada's record_type_definition and record_representation_clause are unique to the language in that the way they are terminated is inconsistant with other declarations which have obvious names like package_declarations and subprogram_declarations. In fact, it is often the case that Ada programmers in the course of typing a record_type_definition accidently type "end identifier" out of force of habit instead of the correct "end record".
We propose introducing an "end identifier" and "end" syntax for record definitions so that their syntax matches subprogram_declarations and package_declarations. See the code segments below for an overview:
type Rec_B is record A : Boolean; B : Boolean; end;
for Rec_B use record A at 0 range 0 .. 0; B at 0 range 1 .. 1; end;
type Rec_B is record A : Boolean; B : Boolean; end Rec_B;
for Rec_B use record A at 0 range 0 .. 0; B at 0 range 1 .. 1; end Rec_B;
As an alternative to:
type Rec_B is record A : Boolean; B : Boolean; end record;
for Rec_B use record A at 0 range 0 .. 0; B at 0 range 1 .. 1; end record;
Here is what the BNF would look like for the proposed changes:
record_definition ::= record component_list end record_terminator | null record
record_terminator ::= [defining_identifier] | [record]
record_representation_clause ::= for first_subtype_local_name use record [mod_clause] {component_clause} end record_representation_terminator;
record_representation_terminator ::= [first_subtype_local_name] | [record]
** Missing!!!
[Editor's note: Given that a record_definition does not have a name (that belongs to some outer construct, how to handle the necessary name checking is the only difficult part of such a proposal. (All existing constructs with a matching identifier have the defining_identifier as part of the construct and thus the rule is obvious.) A proposal without answering that question is clearly not completely thought out. Especially as a record_definition appears in an record_extension.]
It is clear that the addition of the "end identifier" syntax would improve both readability for cases of multi-page records and writability due to progammer habit.
However, allowing "end" alone does not necessarily improve readability. The reasoning behind its inclusion in this proposal is unification. Records defintions, which tend to be much smaller than subprogams and packages declarations, should be allowed to follow the same logic as these declaration constructs and share similar syntax rules.
[Editor's rant: Existing "end identifier" rules apply only to program units. Other constructs (like statements and type declarations) repeat the kind of entity ["end case", "end loop", etc.] That's even true when the constructs have names -- "end loop Loop_Name;"!
Additionally, we can't eliminate any existing syntax possibilities (acknowledged by the author), so there is no chance at making the language any more consistent. In addition, no other kind of type (other than those that double as program units) have any closing identifier, so argubly this change is making Ada less consistent.
Moreover, every Ada style guide and tool enforces a requirement that the matching identifier is not omitted. It's only allowed because it was allowed historically; it is never intentionally used. Therefore, there is little reason to allow it here.
I have sympathy for allowing the "end type_name", as most Ada programmers have written that at some time or other, but without a solution to the name matching problem (especially in record extensions) and with the problem of adding another style question for Ada programmers to argue over ["record" vs. "identifier"], plus allowing yet another case of bad style, I can't support this AI in its current form.
End Editor's Rant.]
[Not sure. Does ASIS expose the matching name at the end of a construct?? - Editor.]
!ACATS test
An ACATS B-Test and C-Test are needed to check that the new capabilities are supported.

From: Justin Squirek
Sent: Wednesday, october 5, 2016  11:30 AM

I was considering amending my previous AI to be several (raise-when syntax
and a with-use clause), but after considering feedback I realized that these
would not blend well with the Ada language.

However, I do think proposing an AI on unifying record type declaration syntax
is worthwhile.

[This is version /01 of this AI, with a number of missing parts added. - Editor]


Questions? Ask the ACAA Technical Agent