40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
The ``++CONST++`` keyword on a subprocedure's parameter indicates that the parameter value will not be changed by the subprocedure. This is not just a nice way to communicate with the programmers who will call the procedure. It also offers performance benefits, because it allows the compiler to produce more optimized code. Further, using ``++CONST++`` means that a field of a similar data type will automatically be converted to the correct type and size for the parameter.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
D X S 15A INZ('ABC')
|
|
|
|
P SubProc1 B
|
|
D SubProc1 PI
|
|
D Parm1 15A // Noncompliant; read-only. Should be CONST
|
|
D Parm2 15A
|
|
/Free
|
|
X = Parm1;
|
|
Parm2 = X;
|
|
return;
|
|
/End-free
|
|
P SubProc1 E
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
D X S 15A INZ('ABC')
|
|
|
|
P SubProc1 B
|
|
D SubProc1 PI
|
|
D Parm1 15A CONST
|
|
D Parm2 15A
|
|
/Free
|
|
X = Parm1;
|
|
Parm2 = X;
|
|
return;
|
|
/End-free
|
|
P SubProc1 E
|
|
----
|
|
|
|
|