Skip to content

Commit 9daad63

Browse files
committed
Rewrite according to feedback and vote
1 parent 6b2ba4a commit 9daad63

File tree

1 file changed

+51
-53
lines changed

1 file changed

+51
-53
lines changed

features/rfc-mandatory_end_designator.md

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,96 +2,94 @@
22
- Start Date: 2025-11-06
33
- Status: Proposed
44

5-
Summary
6-
=======
5+
# Summary
76

8-
This RFC proposes to standardize and mandate the use of the designator name in the end statement for all block-like constructs. Currently, the repetition of the designator (e.g., `end My_Procedure;`) is optional for subprograms, packages, tasks, and protected types. This proposal makes this end designator mandatory in all such cases. As a key part of this standardization, this RFC also proposes to replace the inconsistent end record terminator for record type declarations. This construct will be deprecated in favor of the now-mandatory `end <designator>;` syntax (e.g., `end My_Record_Type;`).
7+
This RFC proposes to standardize the use of a single `end[ designator]` terminator for all declaration constructs that use an end designator, in pedantic Ada Flare.
98

10-
Motivation
11-
==========
9+
Currently, the repetition of the designator (for example, `end My_Procedure`) is optional for subprograms, packages, tasks, and protected types. Record type declarations, however, use a distinct and inconsistent terminator: `end record[ designator]`.
1210

13-
The primary motivation for this change is to improve language consistency and code readability in long or nested code blocks, by explicitly linking the end of a block to its beginning.
11+
This RFC proposes to deprecate the special `end record[ designator]` syntax for record type declarations and replace it with the uniform `end[ designator];` syntax (for example, `end My_Record_Type;`).
1412

15-
The current `end record` syntax is inconsistent with other block terminators. This proposal aligns record declarations with the termination syntax used by subprograms, packages, tasks, and protected types. This change would establish a clear rule: "If a construct has a name in its declaration, that name must be repeated at its end". This rule also finds precedent in Ada's named loops, where a loop's name must be repeated at its `end loop` termination.
13+
For backwards compatibility reasons, non-pedantic Ada Flare continues to accept the Ada 2022 syntax.
1614

17-
In addition, the proposal is particularly well-suited for upcoming language features, such as `class record`s. In such a construct, the `class record body` could be substantially longer, containing the implementations of various methods.
15+
# Motivation
1816

19-
Guide-level explanation
20-
=======================
17+
The primary motivation for this change is to improve language consistency and code readability in long or nested code blocks, by explicitly and uniformily linking the end of a construct to its beginning.
2118

22-
For subprograms, packages, tasks, protected types, record types, class record types and named loops, their name must be repeated at the end. The old syntax, where the name was optional or a different keyword was used (like `end record`), is illegal.
19+
The current `end record[ designator]` syntax is inconsistent with other declaration terminators. This proposal aligns record declarations with the termination syntax used by subprograms, packages, tasks, and protected types.
2320

24-
```ada
25-
-- Old syntax, now illegal
26-
procedure My_Procedure is
27-
begin
28-
null;
29-
end; -- No designator
21+
# Guide-level explanation
3022

31-
-- New syntax, mandatory
32-
procedure My_Procedure is
33-
begin
34-
null;
35-
end My_Procedure; -- Designator is mandatory
36-
```
23+
The special `end record[ designator];` syntax is removed in pedantic Ada Flare and replaced by the generic `end[ designator];` syntax.
3724

38-
The most significant change is to record declarations. The special `end record;` syntax has been removed from the language and replaced by the same universal `end <designator>;` rule.
25+
**Ada Syntax:**
3926

4027
```ada
41-
-- Old syntax, now illegal
42-
type My_Record is record
28+
type My_Record_1 is record
4329
Foo : Unbounded_String;
4430
Bar : Natural;
45-
end My_Record;
31+
end record; -- mandatory 'record'
4632
47-
-- New syntax, mandatory
48-
type My_Record is record
33+
type My_Record_2 is record
34+
Foo : Unbounded_String;
35+
Bar : Natural;
36+
end record My_Record_2; -- mandatory 'record' and optional designator
37+
```
38+
39+
**Flare Syntax:**
40+
41+
```ada
42+
type My_Record_1 is record
4943
Foo : Unbounded_String;
5044
Bar : Natural;
51-
end My_Record; -- Designator is mandatory
45+
end; -- No designator
46+
47+
type My_Record_2 is record
48+
Foo : Unbounded_String;
49+
Bar : Natural;
50+
end My_Record_2; -- With optional designator
5251
```
5352

53+
# Reference-level explanation
5454

55-
Reference-level explanation
56-
===========================
55+
The grammar for record_definition (ARM 3.8) is changed to:
5756

58-
Nothing specific at this stage.
57+
```
58+
record_definition ::=
59+
record
60+
component_list
61+
end[ record_identifier]
62+
| null record
63+
```
5964

60-
Rationale and alternatives
61-
==========================
65+
# Rationale and alternatives
6266

63-
An alternative was to only deprecate `end record;` in favor of an optional `end <record_name>;`. This was deemed a missed opportunity. While it would fix the end record inconsistency, it would not bring the benefits of making the designator mandatory everywhere.
67+
An alternative approach would be to require the designator for all end terminators. This was considered in ealier drafts but rejected in order to preserve the existing Ada philosophy of optional designators for declaration constructs.
6468

65-
Drawbacks
66-
=========
69+
# Drawbacks
6770

68-
The primary drawbacks are related to backward compatibility and verbosity.
71+
The primary drawbacks are related to compatibility. See the Compatibility section below.
6972

70-
For backward compatibility, see the Compatibility section below.
73+
# Compatibility
7174

72-
Mandating the designator makes the code more verbose, as it will be required to type the designator at the end of every block. This is a trade-off and the benefit of improved readability and consistency is argued to outweigh the inconvenience of extra typing.
75+
Code using the new `end[ designator]` syntax for record type declarations will not compile with standard Ada 2022 compilers.
7376

74-
Compatibility
75-
=============
77+
In pedantic Ada Flare, the `end record[ designator]` form is rejected and only the generic terminator is accepted.
7678

77-
This is a significant breaking change. All existing Ada code that currently uses the optional designator (or `end record`) would become non-compliant.
79+
In non-pedantic Ada Flare, both the Ada 2022 and the Ada Flare syntax remain valid to preserve backward compatibility.
7880

79-
Open questions
80-
==============
81+
# Open questions
8182

8283
None at this stage.
8384

84-
Prior art
85-
=========
85+
# Prior art
8686

87-
Ada itself has named loops, (e.g., `Outer_Loop: loop ... end loop Outer_Loop;`) which already enforce the proposed pattern.
87+
None at this stage.
8888

89-
Unresolved questions
90-
====================
89+
# Unresolved questions
9190

9291
None at this stage.
9392

94-
Future possibilities
95-
====================
93+
# Future possibilities
9694

9795
Nothing specific at this stage.

0 commit comments

Comments
 (0)