× 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 2023-08-25 10:23 a.m., Vinay Gavankar wrote:

Since RPG internally passes the parm as an address of the variable, is
there any performance advantage in passing the address of the variable as a
parm instead of the variable itself when the variable is large (say 2K).
...

If you're asking about passing the address of a variable by value vs passing the variable by reference ...

They both behave the same, with the same performance. But passing a variable by reference is generally good and passing its address by value is generally bad.

dcl-pr p1;
salary packed(9:2);
end-pr;
dcl-s emp_sal packed(9:2);
p1 (emp_sal);

dcl-pr p2;
salary pointer value;
end-pr;
dcl-s emp_sal packed(9:2);
p2 (%addr(emp_sal));

The problem with p2 is that the compiler can't help you pass the correct parameter.

dcl-s emp_name varchar(20);

p1 (emp_name);
- You will get an error at compile time. That is good.

p2 (%addr(emp_name));
- The program will compile, but it will have a bug. It is always harder to find the cause of a bug at runtime than at compile time.


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.