Contents | Prev | Next | Index
The purpose of a procedure call is to activate a procedure, execute its code, return to the caller and continue execution at the point immediately following the procedure call. Modula-2 also permits nested procedure calls. The procedure call may contain a list of actual parameters which replace the corresponding formal parameters defined in the procedure declaration. The correspondence is established by the positions of the parameters in the actual and formal parameter lists. There are two kind of parameters: Variable parameters and value parameters.
If a formal parameter is a variable parameter, the corresponding actual parameter must be a designator denoting a variable. If it denotes an element of a structured variable, the component selectors are evaluated when the formal/actual parameter substitution takes place, which is normally just before the execution of the procedure. If a formal parameter is a value parameter, the corresponding actual parameter must be an assignment compatible expression. The value of this expression is assigned to the formal parameter.
procedure_call ::= proc_designator ::= proc_designator actual_parameters proc_designator ::= designator actual_parameters ::= ( param_list ) ::= ( ) param_list ::= param_list , param_expr ::= param_expr param_expr ::= expr |
Examples:
WriteInt(i*2+1) | (* see procedure declaration examples *) |
t^.Insert("John") | (* see type-bound procedure examples *) |
INC(w[k].count) |
Contents | Prev | Next | Index
Canterbury Modula-2 for Java (Last documentation update
Feb 8, 2000)
Copyright © 1998 Mill Hill &
Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to
mhc@webcom.com