Conformance for Parameters and Returning Items

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:

Parameters

The number of arguments in the activating element must be equal to the number of formal parameters in the activated element,

ISO2002MFwith 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.

MFIf 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.

Group 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.

Elementary Items

The conformance rules for elementary items depend on whether the argument is passed by reference, by content, or by value.

Elementary Items Passed by Reference

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:

  1. 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.
  2. 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.
  3. 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.
  4. If the formal parameter is described with the ACTIVE-CLASS phrase, one of the following conditions must be true:
    1. 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.
    2. 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:

  1. 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.
  2. If the activated element is one of the following:

    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:

    1. Currency symbols match if and only if the corresponding currency strings are the same.
    2. 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:

    1. If the formal parameter is described with the ANY LENGTH clause, its length is considered to match the length of the corresponding argument.
    2. If the argument is described with the ANY LENGTH clause, the corresponding formal parameter shall be described with the ANY LENGTH clause.

Elementary Items Passed by Content or by Value

If the formal parameter is an object reference described with the ACTIVE-CLASS phrase, one of the following conditions must be true:

  1. 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.
  2. 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:

  1. 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.
  2. If the activated unit is one of the following:

    then the conformance rules depend on the type of the formal parameter as specified in the following rules:

    1. 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.
    2. 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.
    3. If the formal parameter is described with the ANY LENGTH clause, its length is considered to match the length of the corresponding argument.
    4. 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.

Returning Items

A returning item must be specified in the activating statement, if and only if a returning item is specified in the PROCEDURE DIVISION header

MFor 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.

Group 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.

Elementary Items

If either of the operands is an object reference, the corresponding item must be an object reference, and the following rules apply:

  1. 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.
  2. 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:
    1. If the activated method is invoked with a class-name, the sending operand is described with the same class-name and an ONLY phrase.
    2. If the activated method is invoked with the predefined object references SELF or SUPER

      MFor SELFCLASS

      , the sending operand is described with an ACTIVE-CLASS phrase.

    3. If the activated method is invoked with an object reference described with an interface-name, the sending operand is a universal object reference.
    4. 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.
    5. 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:

  1. Currency symbols match if and only if the corresponding currency strings are the same.
  2. 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.
  3. 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:

  1. If the receiving operand is described with the ANY LENGTH clause, the sending operand must also be described with the ANY LENGTH clause.
  2. 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.