× 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.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.