Version 1.1 of ai12s/ai12-0408-1.txt
!standard 6.1(30/3) 20-12-02 AI12-0408-1/01
!standard 6.7(3/3)
!standard 6.7(4/3)
!standard 6.8(3.1/5)
!standard 6.8(7/4)
!class binding interpretation 20-12-02
!status work item 20-12-02
!status received 20-10-
!priority Low
!difficulty Easy
!qualifier Clarification
!subject Definition of "null procedure" and "expression function".
!summary
We clarify the definition of the term "null procedure" so that it applies
only to procedures whose declaration is a null_procedure_declaration.
A similar clarification is applied to the term "expression function".
!question
Is a procedure that has a "normal" declaration but is completed with a
null_procedure_declaration considered a "null procedure"? (No.)
!response
The definition of "null procedure" is a bit ambiguous now that a null procedure
declaration can be used as a completion. 6.1(30/3) (marked redundant) says
that a subprogram DECLARED by a null_procedure_declaration is a null procedure,
while a subprogram declared by a normal subprogram_declaration is not.
6.7(3/3) says that "a null_procedure_declaration declares a null
procedure" as well as allowing it to complete another subprogram.
A completion never declares anything, so it is clear from these rules that
a completion is not a null procedure. But it probably isn't clear to a
casual reader. Moreover, since a completion is not a null procedure, we don't
have any definition of the execution of a null_procedure_declaration that is
a completion.
!wording
Modify 6.7(3/3):
A null_procedure_declaration {that is not a completion} declares a
/null procedure/. A completion is not allowed for a
null_procedure_declaration; however, a null_procedure_declaration can
complete a previous declaration.
Modify 6.7(4/2):
The execution of a null procedure is invoked by a subprogram call. For
the execution of a subprogram call on a null procedure{, or a
procedure completed with a null_procedure_declaration}, the execution
of the subprogram_body has no effect.
Modify 6.8(3.1/5):
An expression_function_declaration {that is not a completion} declares an
expression function. The return expression of an expression function is the
expression or aggregate of the expression_function_declaration. A completion
is not allowed for an expression_function_declaration; however, an
expression_function_declaration can complete a previous declaration.
Modify 6.8(7/4):
The execution of an expression function is invoked by a subprogram call. For
the execution of a subprogram call on an expression function{, or a
function completed with a expression_function_declaration}, the execution
of the subprogram_body executes an implicit function body containing only
a simple_return_statement whose expression is the return expression that
of the expression function.
!discussion
Whether or not a procedure is a "null procedure" is relevant to certain
legality rules. In particular, when specifying certain aspects on a procedure
declaration, the legality may depend on whether the procedure is a null
procedure. Clearly, such a legality rule cannot depend on how the procedure
is completed, since the completion might well be in a separate compilation
unit.
When a procedure is completed with a null_procedure_declaration, it should be
indistinguishable from a procedure completed with a body of "... is begin
null; end;". If No_Return is specified on the declaration of such a procedure,
one should expect Program_Error to be propagated if the procedure is invoked.
Clearly the compiler could give a warning if it compiles a
null_procedure_declaration as the body for such a procedure, just as it could
warn if the procedure has a body of "... is begin null; end;".
Similar issues arise whether or not a function is an "expression function".
!ASIS
No ASIS effect.
!ACATS test
One could create an ACATS test to check the cases mentioned in the discussion,
but those are unlikely in practice (and the No_Return one represents a program
bug).
!appendix
From: Tucker Taft
Sent: Tuesday, October 27, 2020 2:47 PM
The definition of "null procedure" is a bit ambiguous now that a null procedure
declaration can be used as a completion. This tripped up one of our engineers.
A procedure is *not* a null procedure unless its *declaration* is a
null_procedure_declaration. If its *completion* is a
null_procedure_declaration, then from the language rules point of view it is
*not* a "null procedure," e.g. with respect to the rule that the No_Return
aspect cannot be specified True for a null procedure.
Hence, I would suggest we tweak the wording in 6.7(3/3):
A null_procedure_declaration {that is not a completion} declares a /null
procedure/. A completion is not allowed for a null_procedure_declaration;
however, a null_procedure_declaration can complete a previous declaration.
****************************************************************
From: Steve Baird
Sent: Tuesday, October 27, 2020 2:56 PM
I agree that this would be a useful clarification.
****************************************************************
Questions? Ask the ACAA Technical Agent