-
Notifications
You must be signed in to change notification settings - Fork 30
RFC for mandatory end designators #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
joaopsazevedo
wants to merge
2
commits into
master
Choose a base branch
from
mr/mandatory_end_designators
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| - Feature ID: mandatory_end_designator | ||
| - Start Date: 2025-11-06 | ||
| - Status: Proposed | ||
|
|
||
| # Summary | ||
|
|
||
| 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. | ||
|
|
||
| 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]`. | ||
|
|
||
| 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;`). | ||
|
|
||
| For backwards compatibility reasons, non-pedantic Ada Flare continues to accept the Ada 2022 syntax. | ||
|
|
||
| # Motivation | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| # Guide-level explanation | ||
|
|
||
| The special `end record[ designator];` syntax is removed in pedantic Ada Flare and replaced by the generic `end[ designator];` syntax. | ||
|
|
||
| **Ada Syntax:** | ||
|
|
||
| ```ada | ||
| type My_Record_1 is record | ||
| Foo : Unbounded_String; | ||
| Bar : Natural; | ||
| end record; -- mandatory 'record' | ||
|
|
||
| type My_Record_2 is record | ||
| Foo : Unbounded_String; | ||
| Bar : Natural; | ||
| end record My_Record_2; -- mandatory 'record' and optional designator | ||
| ``` | ||
|
|
||
| **Flare Syntax:** | ||
|
|
||
| ```ada | ||
| type My_Record_1 is record | ||
| Foo : Unbounded_String; | ||
| Bar : Natural; | ||
| end; -- No designator | ||
|
|
||
| type My_Record_2 is record | ||
| Foo : Unbounded_String; | ||
| Bar : Natural; | ||
| end My_Record_2; -- With optional designator | ||
| ``` | ||
|
|
||
| # Reference-level explanation | ||
|
|
||
| The grammar for record_definition (ARM 3.8) is changed to: | ||
|
|
||
| ``` | ||
| record_definition ::= | ||
| record | ||
| component_list | ||
| end[ record_identifier] | ||
| | null record | ||
| ``` | ||
|
|
||
| # Rationale and alternatives | ||
|
|
||
| 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. | ||
|
|
||
| # Drawbacks | ||
|
|
||
| The primary drawbacks are related to compatibility. See the Compatibility section below. | ||
|
|
||
| # Compatibility | ||
|
|
||
| Code using the new `end[ designator]` syntax for record type declarations will not compile with standard Ada 2022 compilers. | ||
|
|
||
| In pedantic Ada Flare, the `end record[ designator]` form is rejected and only the generic terminator is accepted. | ||
|
|
||
| In non-pedantic Ada Flare, both the Ada 2022 and the Ada Flare syntax remain valid to preserve backward compatibility. | ||
|
|
||
| # Open questions | ||
|
|
||
| None at this stage. | ||
|
|
||
| # Prior art | ||
|
|
||
| None at this stage. | ||
|
|
||
| # Unresolved questions | ||
|
|
||
| None at this stage. | ||
|
|
||
| # Future possibilities | ||
|
|
||
| Nothing specific at this stage. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did not mention the alternative of making this a self-imposed Restriction rather than a massive incompatibility. You could allow the alternative syntax for ending a record, and then define a Restriction that would mandate it for a given project.