Parameters and Arguments

The usefulness of a procedure block is increased greatly if it can be made to operate on different values each time it is called. Arguments and parameters enable such operation.

Arguments are the values passed to a procedure block at invocation. Parameters are the names used by the invoked procedure block to refer to these arguments.

Open PL/I typically passes an argument to an invoked procedure by referencing its storage address.

For example:

   CALL P(A,B);
      .
      .
      .
   CALL P(D,E);
      .
      .
      .
P: PROCEDURE(X,Y);
      .
      .
      .
   PUT FILE (F) LIST(X,Y);
      .
      .
      .
   END P;

In this example, A and B are arguments of the first call to the procedure P. While P is executing as a result of the first call, the argument A is said to correspond to the parameter X and the argument B corresponds to the parameter Y. While P is executing as a result of the second call, D corresponds to X and E corresponds to Y.

When an argument is a variable, the actual address of the variable is passed to the called procedure. This allows the invoked procedure to change the value of the argument.

When an argument is a constant or an expression, a temporary location is used to store the current value of the argument, and the address of that temporary location is passed to the called procedure.