×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
On Sun, Sep 16, 2012 at 2:05 PM, Rory Hewitt <rory.hewitt@xxxxxxxxx> wrote:
1. Is there any difference between what is generated at a low-level (W-code
or whatever) for "A = A + B" and "A += B"? I assume not, and that the
difference is merely in the RPG, but I don't know whether the compiler can
make any optimization based on the second example.
According to the RPG manual, in the entry for EVAL:
===begin quote===
For the assignment operators +=, -=, *=, /=, and **=, the appropriate
operation is
applied to the result and the expression, and the result is assigned
to the result.
For example, statement X+=Y is roughly equivalent to X=X+Y. The difference
between the two statements is that for these assignment operators, the result
operand is evaluated only once. This difference is significant when
the evaluation
of the result operation involves a call to a subprocedure which has
side-effects, for
example:
warnings(getNextCustId(OVERDRAWN)) += 1;
===end quote===
I would imagine also that there could be an impact to performance if
evaluating X is very expensive. Though I'd guess both the side-effect
and performance-affecting cases are quite rare in real-world code.
John
As an Amazon Associate we earn from qualifying purchases.