Annotated Ada Reference Manual (Ada 202y Draft 1)Legal Information
Contents   Index   References   Search   Previous   Next 

6.7 Null Procedures

1/2
{AI95-00348-01} A null_procedure_declaration provides a shorthand to declare a procedure with an empty body. 

Syntax

2/3
{AI95-00348-01} {AI05-0183-1} null_procedure_declaration ::= 
   [overriding_indicator]
   procedure_specification is null
       [aspect_specification];

Legality Rules

2.1/3
 {AI05-0177-1} If a null_procedure_declaration is a completion, it shall be the completion of a subprogram_declaration or generic_subprogram_declaration. The profile of a null_procedure_declaration that completes a declaration shall conform fully to that of the declaration.

Static Semantics

3/5
{AI95-00348-01} {AI05-0177-1} {AI05-0264-1} {AI12-0408-1} 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. 
3.a/2
Reason: There are no null functions because the return value has to be constructed somehow; a function that always raises Program_Error doesn't seem very useful or worth the complication.

Dynamic Semantics

4/5
{AI95-00348-01} {AI12-0408-1} The execution of a null procedure is invoked by a subprogram call. For the execution of a subprogram call on a null procedure, or on a procedure completed with a null_procedure_declaration, the execution of the subprogram_body has no effect. 
4.a/2
Ramification: Thus, a null procedure is equivalent to the body 
4.b/2
begin
   null;
end;
4.c/2
with the exception that a null procedure can be used in place of a procedure specification. 
5/3
{AI95-00348-01} {AI05-0177-1} The elaboration of a null_procedure_declaration has no other effect than to establish that the null procedure can be called without failing the Elaboration_Check. 

Examples

6/5
{AI12-0429-1} Example of the declaration of a null procedure: 
7/5
{AI95-00433-01} {AI12-0440-1} procedure Simplify(Expr : in out Expression) is null; -- see 3.9
-- By default, Simplify does nothing, but it can be overridden in extensions of Expression

Extensions to Ada 95

7.a/2
{AI95-00348-01} Null procedures are new. 

Extensions to Ada 2005

7.b/3
{AI05-0177-1} A null_procedure_declaration can now be a completion.
7.c/3
{AI05-0183-1} An optional aspect_specification can be used in a null_procedure_declaration. This is described in 13.1.1

Wording Changes from Ada 2012

7.d/5
{AI12-0408-1} Clarified the term “null procedure” so it matches the meaning expected in 6.1

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe