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



Dave

I think it is optional to copy the memory when using CONST - the 7.3 manual says this -

<<When the keyword CONST is specified, the compiler may copy the parameter to a temporary defined with the same data type and length as the prototyped parameter and pass the address of the temporary. Some conditions that would cause this are: the passed parameter is an expression or the passed parameter has a different format.>>

The left and right arrows denote a new or changed part of the documentation. So maybe this wasn't clearly stated. Note the words "..may copy...".

I think when using VALUE a copy of the data is always made, then a pointer to THAT is passed. Again, this wasn't clearly stated in the 7.3 manual, but other places on the 'Net say this.

CONST is also called read-only reference.

Cheers
Vern

On 4/12/2019 9:44 AM, dlclark@xxxxxxxxxxxxxxxx wrote:
"RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> wrote on 04/12/2019
10:11:54 AM:
So my question is this: What is the best practice (most efficient)
for the Procedure Interface on my new procedure (function)?

Should I

1. Just define the DS the same and pass it in (it could be CONST)

2. Define only the fields I need (and hope I don't need any
additional in the future)

3. Define the PI as pointer and pass the address

Just pass your data structure name. RPG actually only passes a
pointer in this case.

But, I wouldn't recommend using the CONST keyword. The manual
says that using this keyword causes RPG to first copy the parameter value
to another location in the caller's space and then passes a pointer to the
copy. Thus, there would be additional overhead to copy large data areas
to another location in memory. On return, the copy is simply discarded so
that your original data structure is unchanged. If you really need your
data structure to be protected from modification by the called process
then, yes, use the CONST keyword.


Sincerely,

Dave Clark


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.