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

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

!standard 3.8(3)          19-01-10 AI12-0213-1/02
!standard 3.8(7)
!standard 3.8(8)
!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
!summary
*** Missing.
!problem
Ada's record_type_definition and record_representation_clause are unique to the language in that it is the only kind of type definition to feature an enclosed list of components, and being that it is not a program unit or a named construct such as a loop it was classically not considered relevant to allow an identfier with its enclosing "end." However, many Ada users can attest to having records with upwards of 15 or more components complete with comments and whitespace leaving the enclosing "end record" to be below the page of start of the type declaration - meaning some benefit would arise from being able to label the "end record" with the type identifier.
!proposal
We propose introducing an "end record identifier" syntax for record definitions (and thusly representation clauses) so that their syntax more closely matches program units such as subprogram_declarations and package_declarations. See the code segments below for an overview of the proposed change:
type Rec_B is record A : Boolean; B : Boolean; end record Rec_B;
for Rec_B use record A at 0 range 0 .. 0; B at 0 range 1 .. 1; end record 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;
Syntax
Here is what the BNF would look like for the proposed changes:
record_definition ::= record component_list end record_terminator | null record
record_terminator ::= record [record_identifier]
record_representation_clause ::= for first_subtype_local_name use record [mod_clause] {component_clause} end record_representation_terminator;
record_representation_terminator ::= record [first_subtype_local_name]
!wording
Replace 3.8(3)
record_definition ::= record component_list end record_terminator | null record
Add after 3.8(3)
record_terminator ::= record [record_identifier]
Add after 3.8(7)
The optional record_identifier within a given record_definition's record_termintor must match the name of its enclosing type_declaration.
Replace 3.8(28)
type Complex is record Re : Real := 0.0; Im : Real := 0.0; end record Complex;
Replace 13.5.1(2)
record_representation_clause ::= for first_subtype_local_name use record [mod_clause] {component_clause} end record_representation_terminator;
Add after 13.5.1(2)
record_representation_terminator ::= record [first_subtype_local_name]
!ASIS
[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.
!appendix

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]

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

From the minutes of the Lexington Meeting (October 2018):

Tucker suggests "end record <id>"; as an option, there is no interest in leaving
out the record. End by itself is disgusting.

Gary suggests that we would allow the name on end of the record representation
clause. Tucker argues against that, it doesn't declare anything. Others argue
that it could improve readability; it also would be consistent, otherwise you
would have to worry about the context of end record. We eventually agree that it
makes sense to allow it anywhere end record occurs.

The optional identifier has to match appropriately. Randy complains that a
record_definition (which is the construct with the end record) does not iteself
have an identifier. Rather, it is part of other constructs
(record_type_definition, record_extension) which themselves in turn are part of
a type_declaration, which is where the defining identifier comes from. So it is
not simple to describe the identifier that has to match. It should be possible
to describe this (perhaps by saying the "enclosing type_declaration"), we'll
leave it to the author to figure that out.

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

From: Justin Squirek
Sent: Thursday, January 10, 2019  10:21 AM

Attached is my homework for AI12-0213-1-01, revised as per our discussions.
[This is version /02 - Editor.]

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


Questions? Ask the ACAA Technical Agent