× 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 2012/9/16 2:05 PM, Rory Hewitt 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.


The compiler doesn't make any optimizations other than only evaluating A once.

There's a possible optimization that the compiler could make, but doesn't: it currently builds the value A + B and then assigns it to A, but ideally, it would simply append B to the end of A.

The reason that it doesn't is a resource/priority issue. Adding += for strings as it was implemented was relatively low-cost, but making it do a true append for strings would be quite costly in terms of resource.

So, currently, the main benefit (and it's not a small benefit) of the short-form assignment operators is maintainability and readability of code.



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.