Version 1.2 of ai05s/ai05-0205-1.txt

Unformatted version of ai05s/ai05-0205-1.txt version 1.2
Other versions for file ai05s/ai05-0205-1.txt

!standard 8.3(16)          10-04-02 AI05-0205-1/02
!standard 8.3(17/2)
!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
!priority Low
!difficulty Easy
!qualifier Omission
!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; -- Error? (No.)
end return;
The reference to X in the body is illegal by 8.3(16) as it is hidden from all visibility.
This cannot be what was intended (X wouldn't be visible anywhere). What is intended?
(See Summary.)
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 8.3.
!corrigendum 8.3(17/2)
Insert after the paragraph:
the new paragraph:
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
   end return;

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
is intended.

I think this will need to be fixed, probably by rearranging 6.5(2.1/3) to say

   return extended_return_variable_specification [do
   end return];

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