CL Programming

The Call Stack

You can use the Display Debug (DSPDBG) command to display the call stack, which indicates:

A call of a program is the allocation of automatic storage for the program and the transfer of machine processing to the program. A series of calls is placed in a call stack. When a program finishes processing or transfers control, it is removed from the call stack. For more information about the call stack, see "Controlling Flow and Communicating between Programs and Procedures".

A program may be called a number of times while the first call is still in the call stack. Each call of a program is a recursion level of the program.

When a call is ended (the program returns or transfers control), automatic storage is returned to the system.

Notes:

  1. CL programs can be recursive; that is, a CL program can call itself either directly or indirectly through a program it has called.

  2. Some high-level languages do not allow recursive program calls. Other languages allow not only programs to be recursive, but also procedures within a program to be recursive. (In this guide, the term recursion level refers to the number of times the program has been called in the call stack. A procedure's recursion level is referred to explicitly as the procedure recursion level.)

  3. All CL commands and displays make use of only the program qualified name recursion level.

Program Activations

An activation of a program is the allocation of static storage for the program. An activation is always ended when one of the following happens:

In addition, an activation can be destroyed by actions taken during a program call. These actions are dependent on the language (HLL or CL) in which the program is written.

When a program is deactivated, static storage is returned to the system. The language (HLL or CL) in which the program is written determines when the program is normally deactivated. A CL program is always deactivated when the program ends.

An RPG/400(R) program is deactivated when the last record indicator (LR) is set on before the program ends. If there is a return operation and LR is off, the program is not deactivated.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]