IBM AS/400 Frozen Dessert Maker User Manual


 
Program/Procedure Call Overview
PGM X
PRC_B
PRC_A
PRC_C
Recursive Call
Call Stack (bottom entry is most recent)
PRC_A
Figure 60. Recursive Call Stack To Be Avoided
So while subprocedures can be called recursively, if you are not aware that
recursion is occurring, you may exhaust system resources.
Attention!
Unconditional recursive calls can lead to infinite recursion which leads to exces-
sive use of system resources. Infinite recursion can be avoided with proper pro-
gramming. In general, a proper recursive procedure begins with a test to
determine if the desired result has been obtained. If it has been obtained, then
the recursive procedure returns to the most recent caller.
Parameter-Passing Considerations
When designing a call interface, you must make a number of decisions in terms of
how parameters will be passed. On the other hand, if you are the caller then then
most of the decisions have already been made for you. The following lists some of
the parameter-passing considerations to keep in mind when you are designing a
call interface.
Compile-time parameter checking
The call interface of a prototyped call is checked at compile time. This checking
ensures that:
the data types are correctly used
all required parameters are passed
*OMIT is only passed where it is allowed.
Parameter passing method
Each HLL provides one or more ways of passing parameters. These may
include: passing a pointer to the parameter value, passing a copy of the value,
or passing the value itself.
Passing operational descriptors
Chapter 10. Calling Programs and Procedures 131