Version 1.2 of ai05s/ai05-0205-1.txt
!standard 8.3(16) 10-04-02 AI05-0205-1/02
!class binding interpretation 10-02-15
!status Amendment 2012 10-04-02
!status ARG Approved 10-0-0 10-02-28
!status work item 10-02-15
!status received 09-12-05
!subject An extended return statement declares a name usable inside the statement
An extended_return_statement declares a name for a return object that is
visible after the reserved word "do" (if any).
3.1(6) defines an extended_return_statement to be a declaration of its
defining_identifier. 8.3(16) says that a declaration is hidden from all
visibility until the end of the declaration. This means that in:
return X : T do
X := Foobar; --
The reference to X in the body is illegal by 8.3(16) as it is hidden from
This cannot be what was intended (X wouldn't be visible anywhere). What is
Add after 8.3(17/2):
* For an extended_return_statement, the declaration is hidden from all
visibility only until the reserved word do of the statement;
Clearly, the intent is that the name is visible in the
handled_sequence_of_statements of the extended_return_statement. Any other
interpretation about make extended returns pointless.
The alternative of changing the syntax is heavier than simply adopting a rule
similar to that used for program units. Thus we add an additional bullet to
Insert after the paragraph:
- For a record type or record extension, the declaration is hidden from
all visibility only until the reserved word record;
the new paragraph:
- For an extended_return_statement, the declaration is hidden from
all visibility only until the reserved word do of the statement;
Any extended return statement test will implicitly check this rule.
!topic Definition of "declaration" is wrong for extended returns
!reference RM 3.1(6/2), 6.5, 8.3(16)
!from Adam Beneschan 09-12-07
I believe that 3.1(6/2) is worded incorrectly with respect to extended returns.
This makes a difference because of the rule in 8.3(16), "A declaration is hidden
from all visibility until the end of the declaration, except..." with some
exceptions that don't apply here.
In this case:
procedure P (I : Integer := I + 1);
the declaration is illegal because the declaration of the parameter I is hidden
from all visibility until the end of its declaration. The way we know where the
declaration ends is from 3.1(6), which says that parameter_specification is
defined to be one kind of declaration---and the parameter_specification syntax
includes everything up through the default expression, if any.
But for an extended return variable, 3.1(6) says that the declaration is the
entire extended_return_statement. This would mean that:
return X : T do
the "end of the declaration" is the "end return;" text, and 8.3(16) would then
mean X could not be referred to at all in the <body>!!! Clearly this is not what
I think this will need to be fixed, probably by rearranging 6.5(2.1/3) to say
return extended_return_variable_specification [do
with extended_return_variable_specification taking care of the syntax that is
already there, and then by removing the last sentence of 3.1(6) and adding
extended_return_variable_specification to the list.
Questions? Ask the ACAA Technical Agent