The conformance rules for parameters and returning items apply at compile
time when an explicit reference is made to them from a syntax rule.
注意: Conformance rules for parameters and returning items are checked at compile
time for:
- An INVOKE statement on an object reference that is not a universal object
reference,
- A reference to a user-defined function,
- A program-prototype format of the CALL statement.
The number of arguments in the activating element must be equal to the number
of formal parameters in the activated element,

with the exception of trailing formal parameters that are specified with
an OPTIONAL phrase in the PROCEDURE DIVISION header of the activated element
and are omitted from the list of arguments of the activating element.
If the numbers of operands are different, then if there are more operands
in the activating statement, they are ignored and if there are more operands
in the PROCEDURE DIVISION header, they must not be referenced within the activated
runtime element. The positional correspondence may vary depending on the non-COBOL
calling conventions implied by mnemonic-name. Any mismatch in the number of
the operands will only be apparent at run time and so the directive FLAG does
not cause this extension to be flagged.
The rules for conformance between arguments and formal parameters depend
on whether either the formal parameter or its corresponding argument is a
group item or both are elementary items.
If either the formal parameter or the argument is a group item, the corresponding
argument or formal parameter must be a group item or an elementary item of
category alphanumeric, and the formal parameter must be described with the
same number or a smaller number of character positions as the corresponding
argument.
The conformance rules for elementary items depend on whether the argument
is passed by reference, by content, or by value.
If either the formal parameter or the corresponding argument is an object
reference, the corresponding argument or formal parameter must be an object
reference following these rules:
- If either the argument or the formal parameter is a universal object reference,
the corresponding formal parameter or argument must be a universal object
reference.
- If either the argument or the formal parameter is described with an interface-name,
the corresponding formal parameter or argument must be described with the
same interface-name.
- If either the argument or the formal parameter is described with a class-name,
the corresponding formal parameter or argument must be described with the
same class-name, and the FACTORY and ONLY phrases must be the same.
- If the formal parameter is described with the ACTIVE-CLASS phrase, one of
the following conditions must be true:
- The argument must be an object reference described with the ACTIVE-CLASS
phrase, where the presence or absence of the FACTORY phrase is the same as
in the formal parameter, and the method to be activated must be invoked with
the predefined object references SELF or SUPER, or with an object reference
described with the ACTIVE-CLASS phrase.
- The argument must be an object reference described with a class-name and
the ONLY phrase, where the presence or absence of the FACTORY phrase is the
same as in the formal parameter, and the method to be activated must be invoked
with that class-name or with an object reference described with that classname
and the ONLY phrase.
If either the argument or the formal parameter is of class pointer, the corresponding
formal parameter or argument must be of class pointer and the corresponding
items must be of the same category. If either is a restricted pointer, both
must be restricted and of the same type. The ADDRESS special register is considered
to be of class pointer and category data-pointer.
If neither the formal parameter nor the argument is of class object or pointer,
the conformance rules are the following:
- If the activated element is a program for which there is no program-specifier
in the Repository paragraph of the activating element and there is no NESTED
phrase specified on the CALL statement, the formal parameter must be of the
same length as the corresponding argument.
- If the activated element is one of the following:
- A program for which there is a program-specifier in the Repository paragraph
of the activating element
- A program that was called with a CALL statement in which the NESTED phrase
is specified
- A method
- A function
then the definition of the formal parameter and the definition of the argument
must have the same PICTURE, USAGE, SIGN, JUSTIFIED, and BLANK clauses, with
the following exceptions:
- Currency symbols match if and only if the corresponding currency strings
are the same.
- Period picture symbols match if and only if the DECIMAL-POINT IS COMMA clause
is in effect for both the activating and the activated runtime elements or
for neither of them. Comma picture symbols match if and only if the DECIMAL-POINT
IS COMMA clause is in effect for both the activating and the activated runtime
elements or for neither of them.
Additionally:
- If the formal parameter is described with the ANY LENGTH clause, its length
is considered to match the length of the corresponding argument.
- If the argument is described with the ANY LENGTH clause, the corresponding
formal parameter shall be described with the ANY LENGTH clause.
If the formal parameter is an object reference described with the ACTIVE-CLASS
phrase, one of the following conditions must be true:
- The method to be activated must be invoked with the predefined object references
SELF or SUPER, or with an object reference described with the ACTIVE-CLASS
phrase, and a SET statement must be valid in the activating unit with the
argument as the sending operand and an object reference described with the
ACTIVE-CLASS phrase as the receiving operand, where the presence or absence
of the FACTORY phrase is the same as in the formal parameter.
- The method to be activated must be invoked with a class-name or with an object
reference described with a class-name and the ONLY phrase, and a SET statement
must be valid in the activating unit with the argument as the sending operand
and an object reference described with that class-name and the ONLY phrase
as the receiving operand, where the presence or absence of the FACTORY phrase
is the same as in the formal parameter.
If the formal parameter is of class pointer or an object reference descrited
without the ACTIVE-CLASS phrase, the conformance rules are the same as if
a SET statement were performed in the activating runtime element with the
argument as the sending operand and the corresponding formal parameter as
the receiving operand.
If the formal parameter is not of class object or pointer, the conformance
rules are the following:
- If the activated element is a program for which there is no program-specifier
in the Repository paragraph of the activating element and there is no NESTED
phrase specified on the CALL statement, the formal parameter must be described
with the same number of character positions as the corresponding argument.
- If the activated unit is one of the following:
- A program for which there is a program-specifier in the Repository paragraph
of the activating element
- A program that was called with a CALL statement in which the NESTED phrase
is specified
- A method
- A function
then the conformance rules depend on the type of the formal parameter as
specified in the following rules:
- If the formal parameter is numeric, the conformance rules are the same as
for a COMPUTE statement with the argument as the sending operand and the corresponding
formal parameter as the receiving operand.
- If the formal parameter is an index or pointer data item, the conformance
rules are the same as for a SET statement with the argument as the sending
operand and the corresponding formal parameter as the receiving operand.
- If the formal parameter is described with the ANY LENGTH clause, its length
is considered to match the length of the corresponding argument.
- Otherwise, the conformance rules are the same as for a MOVE statement with
the argument as the sending operand and the corresponding formal parameter
as the receiving operand.
A returning item must be specified in the activating statement, if and only
if a returning item is specified in the PROCEDURE DIVISION header
or ENTRY statement
of the activated source element. A returning item is implicitly specified
in the activating element when a function or inline method invocation is referenced.
The returning item in the activated source element is the sending operand,
the corresponding returning item in the activating source element is the receiving
operand.
The rules for conformance between the sending operand and the receiving operand
depend on whether at least one of the operands is an alphanumeric group item
or both operands are elementary items.
If either the sending or the receiving operand is a group item, the corresponding
returning item must be a group item or an elementary item of category alphanumeric,
and the receiving operand must be described with the same number of character
positions as the sending operand.
注意: If a returning item in an activating element is a group with a level number
other than 1 and its subordinate items are described such that the implementation
inserts slack bits or bytes, the alignment of the subordinate elementary items
might not correspond between the returning item in the activating runtime
element and the returning item in the activated runtime element.
For an operand that is described as a variable-occurrence data item, the
maximum length is used.
If either of the operands is an object reference, the corresponding item
must be an object reference, and the following rules apply:
- If the returning item in the activated source element is not described with
an ACTIVE-CLASS phrase, the conformance rules are be the same as if a SET
statement were performed in the activated runtime element with the returning
item in the activated source element as the sending operand and the corresponding
returning item in the activating source element as the receiving operand.
- If the returning item in the activated source element is described with an
ACTIVE-CLASS phrase, the conformance rules are the same as if a SET statement
were performed in the activating runtime element with the returning item in
the activating source element as the receiving operand, and a sending operand
described with USAGE OBJECT REFERENCE as determined by the following rules:
- If the activated method is invoked with a class-name, the sending operand
is described with the same class-name and an ONLY phrase.
- If the activated method is invoked with the predefined object references
SELF or SUPER
or SELFCLASS
, the sending operand is described with an ACTIVE-CLASS phrase.
- If the activated method is invoked with an object reference described with
an interface-name, the sending operand is a universal object reference.
- If the activated method is invoked with any other object reference, this
identifier is used as the sending operand, including the ONLY phrase if specified.
- If the sending operand selected by applying the above rules is described
with a class-name or an ACTIVE-CLASS phrase, the presence or absence of the
FACTORY phrase is the same as in the returning item of the activated source
element.
If the sending operand is not an object reference, the receiving operand
must have the same PICTURE, USAGE, SIGN, SYNCHRONIZED, JUSTIFIED, and BLANK
clauses, with the following exceptions:
- Currency symbols match if and only if the corresponding currency strings
are the same.
- Period picture symbols match if and only if the DECIMAL-POINT IS COMMA clause
is in effect for both the activating and the activated runtime elements or
for neither of them.
- Comma picture symbols match if and only if the DECIMAL-POINT IS COMMA clause
is in effect for both the activating and the activated runtime elements or
for neither of them.
Additionally:
- If the receiving operand is described with the ANY LENGTH clause, the sending
operand must also be described with the ANY LENGTH clause.
- If the sending operand is described with the ANY LENGTH clause, the length
of the sending operand is considered to match the length of the receiving
operand.