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



Dennis Lovelady wrote:
For defining a constant field for use in RPG is it more efficient
(when using to compare against) to have a non-changeable "C" type than
a data structure subfield that is initialized?

Unless I'm missing something, there should be no difference. Under the
covers, the constant becomes an addressable field. Both comparisons will be
done by addressing the values to compare.


A constant would probably not become an addressable field. It would just be part of the constant data of the module. The subfield would have to have storage allocated and initialized (the initialization value would be part of the constant data of the module).

But any performance difference either way would be negligible and probably undetectable.

It's still an interesting question, but I don't think performance should be one of the criteria in this case.

What I think are more interesting considerations are:
- the qualified name is easier to understand
- when it's a subfield, it can be modified, so it's not really a constant

If RPG had qualified named constants, it would be a non-issue. But given that RPG doesn't have that feature, I would err on the side of program correctness and use a constant, but I would embed "keyfields" in the name as keyfields_FUNCTYPE to get the enhanced readability.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.