Go to the first, previous, next, last section, table of contents.

6.4 Subprogram Calls

  1. A subprogram call is either a procedure_call_statement or a function_call; it invokes the execution of the subprogram_body. The call specifies the association of the actual parameters, if any, with formal parameters of the subprogram.


  2. procedure_call_statement ::=
       | procedure_prefix actual_parameter_part;
  3. function_call ::=
       | function_prefix actual_parameter_part
  4. actual_parameter_part ::=
       (parameter_association {, parameter_association{)
  5. parameter_association ::=
       [formal_parameter_selector_name =>] explicit_actual_parameter
  6. explicit_actual_parameter ::= expression | variable_name
    1. A parameter_association is named or positional according to whether or not the formal_parameter_selector_name is specified. Any positional associations shall precede any named associations. Named associations are not allowed if the prefix in a subprogram call is an attribute_reference.

Name Resolution Rules

  1. The name or prefix given in a procedure_call_statement shall resolve to denote a callable entity that is a procedure, or an entry renamed as (viewed as) a procedure. The name or prefix given in a function_call shall resolve to denote a callable entity that is a function. When there is an actual_parameter_part, the prefix can be an implicit_dereference of an access-to-subprogram value.
  2. A subprogram call shall contain at most one association for each formal parameter. Each formal parameter without an association shall have a default_expression (in the profile of the view denoted by the name or prefix). This rule is an overloading rule, See section 8.6 The Context of Overload Resolution.

    Dynamic Semantics

  3. For the execution of a subprogram call, the name or prefix of the call is evaluated, and each parameter_association is evaluated, See section 6.4.1 Parameter Associations. If a default_expression is used, an implicit parameter_association is assumed for this rule. These evaluations are done in an arbitrary order. The subprogram_body is then executed. Finally, if the subprogram completes normally, then after it is left, any necessary assigning back of formal to actual parameters occurs, See section 6.4.1 Parameter Associations.
  4. The exception Program_Error is raised at the point of a function_call if the function completes normally without executing a return_statement.
  5. A function_call denotes a constant, as defined in See section 6.5 Return Statements, the nominal subtype of the constant is given by the result subtype of the function.


  6. Examples of procedure calls:
  7. Traverse_Tree;                   --  See section 6.1 Subprogram Declarations
    Print_Header(128, Title, True);  --  See section 6.1 Subprogram Declarations
  8. Switch(From => X, To => Next);
    --  See section 6.1 Subprogram Declarations.
    Print_Header(128, Header => Title, Center => True);
    --  See section 6.1 Subprogram Declarations.
    Print_Header(Header => Title, Center => True, Pages => 128);
    --  See section 6.1 Subprogram Declarations.
  9. Examples of function calls:
  10. Dot_Product(U, V)   --  See section 6.1 Subprogram Declarations, and See section 6.3 Subprogram Bodies.
    Clock               --  See section 9.6 Delay Statements, Duration, and Time.
    --  presuming F is of an access-to-subprogram type
    -- See section 3.10 Access Types.
  11. Examples of procedures with default expressions:
  12. procedure Activate(Process : in Process_Name;
                       After   : in Process_Name := No_Process;
                       Wait    : in Duration := 0.0;
                       Prior   : in Boolean := False);
  13. procedure Pair(Left, Right : in Person_Name := new Person);
    --  See section 3.10.1 Incomplete Type Declarations.
  14. Examples of their calls:
  15. Activate(X);
    Activate(X, After => Y);
    Activate(X, Wait => 60.0, Prior => True);
    Activate(X, Y, 10.0, False);
  16. Pair;
    Pair(Left => new Person, Right => new Person);


  17. (7) If a default_expression is used for two or more parameters in a multiple parameter_specification, the default_expression is evaluated once for each omitted parameter. Hence in the above examples, the two calls of Pair are equivalent.


  18. Examples of overloaded subprograms:
  19. procedure Put(X : in Integer);
    procedure Put(X : in String);
  20. procedure Set(Tint   : in Color);
    procedure Set(Signal : in Light);
  21. Examples of their calls:
  22. Put(28);
    Put("no possible ambiguity here");
  23. Set(Tint   => Red);
    Set(Signal => Red);
  24. --  Set(Red) would be ambiguous since Red may
    --  denote a value either of type Color or of type Light

Go to the first, previous, next, last section, table of contents.