Return
to Chapter 8
Parameters:
-
In the call --- Actual Parameters
(In parent's program)
-
In the header of definition ---- Formal Parameters
(In child's program)
-
The correspondence between actual and formal parameters:
-
Positional Parameters: keep the order.
The 1st actual parameter is bound to the 1st formal parameter and so forth.
-
Keyword Parameters: They can appear in any order in
the actual parameter list.
e.g. In Ada:
In the call:
SUMER(MY_LENGTH,
SUM
=> MY_SUM, LIST => MY_ARRAY)
In the definition: SUMER(LENGTH,
LIST,
SUM)
The 1st parameter is a positional
parameter and rest of them are keyword parameters.
Once keyword parameters used,
no more positional parameter after them.
-
Default Parameter: when subprogram begins, it assume
to pass.
e.g. In Ada:
In the definition: function
COMPUTE_PAY(INCOME:FLOAT;
EXEMPTIONS:INTEGER := 1;
TAX_RATE:FLOAT) return FLOAT;
In the call: COMPUTE_PAY(INCOME
=> MY_INCOME, TAX_RATE => MY_RATE)