IBM AS/400 Frozen Dessert Maker User Manual


 
Passing Prototyped Parameters
Examples of Free-Form Call
For examples of using the CALLP operation, see:
Figure 22 on page 41
Figure 43 on page 97
Figure 105 on page 212
Figure 70 on page 144
Figure 117 on page 242
For examples of calling by using an expression, see:
Figure 4 on page 10
Figure 19 on page 39
Figure 38 on page 79
Figure 105 on page 212
Passing Prototyped Parameters
When you pass prototyped parameters:
The compiler verifies, when compiling both the caller and the callee, that the
parameter definitions match, provided as both are compiled using the proto-
type.
Fewer specifications are needed, since you do not need the PARM operations.
This section discusses the various options that are available when defining proto-
typed parameters, and the impact of these options on the call interface.
Parameter Passing Styles
Program calls, including system API calls, require that parameters be passed by
reference. However, there is no such requirement for procedure calls. ILE RPG
allows three methods for passing and receiving prototyped parameters:
By reference
By value
By read-only reference
Parameters that are not prototyped may only be passed by reference.
Passing by Reference
The default parameter passing style for ILE RPG is to pass by reference. Conse-
quently, you do not have to code any keywords on the parameter definition to pass
the parameter by reference. You should pass parameters by reference to a proce-
dure when you expect the callee to modify the field passed. You may also want to
pass by reference to improve run-time performance, for example, when passing
large character fields. Note also that parameters that are passed on external
program calls can only be passed by reference.
Chapter 10. Calling Programs and Procedures 135