IBM AS/400 manual Parameter-Passing Considerations, Program/Procedure Call Overview

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 155
Image 155
60. Recursive Call Stack To Be Avoided

Program/Procedure Call Overview

PGM X

 

PRC_A

 

PRC_B

 

PRC_C

 

PRC_A

Recursive Call

Call Stack (bottom entry is most recent)

 

 

 

 

 

 

 

 

Figure

60. Recursive Call Stack To Be Avoided

 

 

 

 

 

 

 

So while subprocedures can be called recursively, if you are not

a

recursion is occurring, you

may exhaust system resources.

 

 

 

 

Attention!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Unconditional recursive calls can lead

to

infinite recursion

which

le

sive use of system resources. Infinite recursion can be

avoided

gramming. In general, a proper recursive procedure begins

with a t

determine if the desired result

has

been

obtained.

If

it has

b

the

recursive procedure

returns

to the

most

recent

caller.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Parameter-Passing Considerations

When

designing a call interface, you must make a number

of

decisions

how

parameters will be passed. On the other hand, if

you

are

the

most

of the decisions have already been made for you. The followin

the

parameter-passing considerations to keep in mind when

you

are

des

call

interface.

 

 

 

¹Compile-time parameter checking

The call interface of a prototyped call is checked at compile t 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 m include: passing a pointer to the parameter value, passing a copy or passing the value itself.

¹ Passing operational descriptors

Chapter 10. Calling Programs and Procedures131

Page 155
Image 155
IBM AS/400 manual Parameter-Passing Considerations, Program/Procedure Call Overview, Recursive Call Stack To Be Avoided