SuivantPrec.Bas prec.BasNiv. sup.

9.4 Arguments of External Procedures 

Arguments can pass information into a procedure or out from it, or in both directions. This just depends on the way that the dummy argument is used within the procedure. Although any argument order is permitted, it is common practice to put input arguments first, then those that pass information both ways, and then arguments which just return information from the procedure.

The rules for argument association are the same for both forms of external procedure. The list of dummy arguments (sometimes called formal arguments) of an external procedure is specified in its FUNCTION or SUBROUTINE statement. There can be any number of arguments, including none at all. If there are no arguments then the parentheses can be omitted in the CALL and SUBROUTINE statement but not in a FUNCTION statement or function reference.

The dummy argument list is simply a list of symbolic names which can represent any mixture of

A name cannot, of course, appear twice in the same dummy argument list.

Dummy variables, arrays, and procedures are distinguished only by the way that they are used within the procedure. The dimension bounds of a dummy arrays must be specified in a subsequent type or DIMENSION statement; dummy procedures must appear in a CALL or EXTERNAL statement or be used in a function reference; anything else is, by elimination, a dummy argument variable.

Dummy argument variables and arrays can be used in executable statements in just the same way as local items of the same form, but they cannot appear in SAVE, COMMON, DATA, or EQUIVALENCE statements.

Argument Association 

The actual arguments of the function reference or CALL statement become associated with the corresponding dummy arguments of the FUNCTION or SUBROUTINE statement. The main rules are as follows:

Because program units are compiled independently, it is difficult for the compiler to check for mismatches in actual and dummy argument lists. Although mismatches could, in principle, be detected by the linker, this rarely seems to happen in practice. Errors, particularly mismatches of data type or array bounds, are especially easy to make but hard to detect. Sometimes the only indication is that the program produces the wrong answer. This shows how important it is to check procedure interfaces.

Duplicate Arguments  

The same actual argument cannot be used more than once in a procedure call if the corresponding dummy arguments are assigned new values. For example, with:
        SUBROUTINE FUNNY(X, Y)
        X = 2.0
        Y = 3.0
        END
A call such as:       CALL FUNNY(A, A) would be illegal because the system would try to assign both 2.0 and 3.0 to the variable A.

A similar restriction applies to variables which are returned via a common block and also through the procedure argument list.

SuivantPrec.Bas prec.HautNiv. sup.