
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
65 lines
1.5 KiB
Plaintext
65 lines
1.5 KiB
Plaintext
== Why is this an issue?
|
|
|
|
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
|
|
|
|
[source,rpg]
|
|
----
|
|
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
|
|
|
|
[source,rpg]
|
|
----
|
|
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
|
|
----
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Add the "CONST" keyword to the declaration of "XXX"
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== is duplicated by: S1252
|
|
|
|
=== relates to: S995
|
|
|
|
endif::env-github,rspecator-view[]
|