Library parameters can be passed by value, by reference, by name, or as read-only. The read-only property causes the compiler to select the most efficient parameter-passing mode, and prevents the receiving procedure from modifying the value of the parameter. For an introduction to these parameter-passing modes and read-only parameters, refer to Parameter Passing Modes in Using Parameters.
If the library program declares a parameter to be received as a read-only parameter, the client program can pass the parameter as call-by-name, call-by-reference, call-by-value, or read-only. If a library program declares a parameter to be received by name or by reference, the client program can pass the parameter by name, by reference or by value. If the library program declares a parameter to be received by value, the client program can only pass the parameter by value. For pointer parameters, the parameter-passing mode of the library program and the client program must match.
Parameter-Passing Modes illustrates the parameter-passing rules. In the table, the legal combinations of parameter-passing modes are marked with a P for pointer parameters and an X for all other parameter types.
Table 19. Parameter-Passing Modes
|
Library Program |
Client Program |
|||
|---|---|---|---|---|
|
Read-Only |
Name |
Reference |
Value |
|
|
Read-Only |
X |
X |
X |
X |
|
Name |
X |
X |
X |
|
|
Reference |
X |
P/X |
X |
|
|
Value |
P/X |
|||
In ALGOL programs, parameters are declared with or without a VALUE clause. In ALGOL library programs, parameters declared with a VALUE clause are received by value. Parameters declared without the VALUE clause are received by reference, except for formal procedures and integer, real, double, Boolean, and complex variables, which are received by name. In ALGOL client programs, library procedure parameters declared with a VALUE clause are passed by value. Parameters declared without a VALUE clause are passed by reference, except for integer, real, double, Boolean, and complex variables, which are passed by name.
In COBOL74, parameters are passed by reference; therefore, a COBOL74 client program cannot call a library that has declared its parameters by value. An ALGOL library must declare its parameters to be by name or by reference if the ALGOL library is to be called by a COBOL74 program.
A COBOL74 library must declare its 77-level BINARY parameters to be received by reference. If any BINARY parameter is received by content, the program is not library-capable. Due to the parameter-passing rules and the ALGOL and COBOL74 language restrictions, an ALGOL program that calls a COBOL74 library must declare its integer, real, or double parameters to be by value.
In COBOL85, parameters can be passed by reference or by value. If a COBOL85 program passes a group item of other than 01 level by reference, then the item is passed as call-by-value-result. In other words, the value of the item in the calling program is updated when the library procedure terminates.
In FORTRAN77, variable parameters are passed by name; array parameters are passed by reference.
In NEWP, parameters are declared to be by value or by reference. Integers, real, double, and Boolean variables that are not declared to be by value are passed by reference.
In Pascal, parameters are passed by reference, read-only, or value. Parameters that are not passed by reference (“VAR” parameters) or by read-only (“CONST” parameters) are passed by value.

