Previous Topic Next topic Print topic


Constants vs Variables

If an operand you are using in a PL/I expression, BUILTIN, or any other language construct is a constant value, use a constant, rather than a variable that has been initialized to that constant value; for example:

%replace array_dim by 10; /* or */
DCL array_dim fixed bin(31)
value(10); /* this is a constant NOT a variable */

and

DCL array(array_dim10) fixed bin(31);

is the same as:

DCL array(10) fixed bin(31);

Which is significantly more efficient than:

 DCL arrray_dim fixed bin(31)init(10);
DCL array(array_dim10) fixed bin(31);

Using constant values or compile-time expressions, in many cases, enables the compiler to generate code and/or initialize the data area at compile time, rather than the required code being generated at execution time.

Previous Topic Next topic Print topic