AI22-0080-1
!standard 8.1(1) 24-03-22 AI22-0080-1/04
!standard 8.1(13)
!class Presentation 23-10-05
!status Amendment 1-2022 23-10-05
!status WG9 Approved 24-06-10
!status ARG Approved 12-0-0 23-10-05
!status work item 23-09-26
!status received 23-03-28
!submitter Tucker Taft
!priority Low
!difficulty Medium
!qualifier Clarification
!subject Clarify definition of declarative region
We clarify the definition of declarative region.
Recently an Ada user complained (see issue #42 on ARG GitHub issue list, link in Appendix) that the definition of declarative region in RM 8.1 was unclear:
For each of the following constructs, there is a portion of the program text called its declarative region, within which nested declarations can occur:
The declarative region includes the text of the construct together with additional
text determined (recursively), as follows:
. . .
A declaration occurs immediately within a declarative region if this region is the innermost
declarative region that encloses the declaration (the immediately enclosing declarative region),
not counting the declarative region (if any) associated with the declaration itself.
This wording is very old, and it has probably not been reviewed in 25 years or more. His complaint is that the phrase "within which nested declarations can occur" is confusing, since it made him think that the declarative region contains only places where declarations can occur. He was trying to understand exactly what code a pragma Suppress applies to, and that is defined in terms of declarative regions.
The most important part of the definition of declarative region is probably from the middle paragraph of the above, namely "...includes the text of the construct...".
It is arguable that the "within which nested declarations can occur" is not helping understanding, and can be confusing if it is seen as restrictive in some sense.
Here is a possible alternative:
For each of the following constructs, there is a portion of the program text called
its declarative region:
. . .
The declarative region includes the text of the construct together with additional text determined
(recursively), as follows:
. . .
Nested declarations can occur within a declarative region. A declaration occurs
immediately within a declarative region if this region is the innermost declarative region
that encloses the declaration (the immediately enclosing declarative region), not counting the
declarative region (if any) associated with the declaration itself.
Modify 8.1(1):
For each of the following constructs, there is a portion of the program text called its declarative region[, within which nested declarations can occur]:
Modify 8.1(13):
{Nested declarations can occur within a declarative region. }A declaration occurs immediately within a declarative region if this region is the innermost declarative region that encloses the declaration (the immediately enclosing declarative region), not counting the declarative region (if any) associated with the declaration itself.
It is not clear any change is required, but when you read these paragraphs, it is easy to miss the key phrase saying the "declarative region includes the text of the construct ...", and so one can see how a user might have interpreted the initial phrase saying "within which nested declarations can occur" as definitional.
We reword and move the phrase "within which nested declarations can occur" to later in the section, which should emphasize that this is just a region of text.
No example is needed.
@drepl
For each of the following constructs, there is a portion of the program text called its @i{declarative region}, within which nested declarations can occur:
@dby
For each of the following constructs, there is a portion of the program text called its @i{declarative region}:
@drepl
A declaration occurs @i{immediately within} a declarative region if this region is the innermost declarative region that encloses the declaration (the @i{immediately enclosing} declarative region), not counting the declarative region (if any) associated with the declaration itself.
@dby
@i{Nested} declarations can occur within a declarative region. A declaration occurs @i{immediately within} a declarative region if this region is the innermost declarative region that encloses the declaration (the @i{immediately enclosing} declarative region), not counting the declarative region (if any) associated with the declaration itself.
No semantic change is intended, so no ACATS tests need to be constructed or modified.