Block activation

Each block plays the same role in the allocation and freeing of storage and in delimiting the scope of names. Packages are neither activated nor terminated.

For information about how activation occurs, see Procedures and Begin-blocks.

During block activation, the following operations are performed:

  • Expressions that appear in declare statements are evaluated for extents and initial values (including iteration factors).
  • Storage is allocated for automatic variables. Their initial values are set if specified.
  • Storage is allocated for dummy arguments and compiler-created temporaries that might be created in this block.
Initial values and extents for automatic variables must not depend on the values or extents of other automatic variables declared in the same block. For example, the following initialization can produce incorrect results for J and K:
  dcl I init(10),J init(K),K init(I);
Similarly, the following code causes b to have an undefined value (and most likely, not the value 10) after this structure is initialized:
dcl
  1 a,
    2 b fixed bin init(c),
    2 c fixed bin init(10);
Declarations of data items must not be mutually interdependent. For example, the following declarations are invalid:
  dcl A(B(1)), B(A(1));

  dcl D(E(1)), E(F(1)), F(D(1));

Errors can occur during block activation, and the ERROR condition (or other conditions) can be raised. If so, the environment of the block might be incomplete. In particular, some automatic variables might not have been allocated. Statements referencing automatic variables executed after the ERROR condition has been raised might reference unallocated storage. The results of referring to unallocated storage are undefined.