Search code examples
ibm-midrangerpglerpg

What is usually preferred in a sub-proc, INZ during variable declaration or using CLEAR?


Assuming both choices will yield same results, what choice do you usually make and why?

dcl-proc test_proc ;
   ...
   dcl-s count  int(5) inz ;
   ...
   // use count
end-proc ;

or

dcl-proc test_proc ;
   ...
   dcl-s count  int(5) ;
   ...
   clear count
   // use count
end-proc ;

Also, As the scope of variable count is local, do we even need to use either of them?


Solution

  • You don't need INZ to be able to use RESET.

    But it's best to use RESET only when the RESET value would be different from the CLEAR value.

    Using RESET requires the compiler to generate extra storage and extra instructions to save the initial value.