Using named constants in structures to create more efficient code
bbalk 1200006543 Visits (1087)
Enterprise PL/I has always supported "named constants", i.e. scalars declared with the VALUE attribute, which make your
code more maintainable than using the constants as is, but which also allow the compiler to produce much better code
than scalars declared with the INITIAL attribute.
With Enterprise 4.1 (actually even with 3.9 although it was not documented then), you can now declare named constants in
structures (as long as all the leaf elements of such a structure have the VALUE attribute and as long as the structure contains
no arrays or unions). This allows you to define namespaces of constants and allows you to convert easily a STATIC structure
that consisted of only scalars with the INITIAL attribute to a structure for which the compiler can generate much better code.
For example, if you had this structure,
1 group_rcs static,
2 ok fixed bin(31) init(0),
2 warning fixed bin(31) init(1),
2 error fixed bin(31) init(3);
you could convert it to
2 ok fixed bin(31) value(0),
2 warning fixed bin(31) value(1),
2 error fixed bin(31) value(3);
and the references to group_rcs.ok, group_rcs.warning and group_rcs.error in your code would work more efficiently
without any change.