rspec/rules/S1900/rpg/rule.adoc

40 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
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.
2021-04-28 16:49:39 +02:00
== 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
----
2021-04-28 16:49:39 +02:00
== 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
----