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



Hi Barbara,

<snip>
No, you're thinking of program calls; the parameters to programs are passed
as an array of pointers (but without the operational descriptor).
</snip>

OK, I need to get this straight. When we call a ILE rpg program we don't
work with this array directly do we? The values are put into the parms of
the PEP. Is that right? I'm guessing that the call to the PEP is an internal
bound call so it would work in the same way as a bound subprocedure call.
Are there differences between the way parms are passed during a call to the
PEP and during a call to a subprocedure?

<snip>
The parameters to bound procedures are passed individually. When you pass a
parameter by value, the OS really does copy the entire parameter value as
part of low-level parameter passing. (This is additional to any copying that
the RPG compiler does to create temporaries due to type or size differences;
that _is_ usually the same for CONST and VALUE.)
</snip>

So...

1) When passing a parameter by value the OS (at a low-level) always copies
the entire value to another variable. When passing by constant reference
this is not the case and the original variable is used.
2) In both cases above, if the variable to be passed requires "casting" then
the data is copied to a tempory. It is the address of this temporary which
is passed on the bound call.

From this I would infer that passing long strings by value when there is a
length mismatch will involve two copies of the data being made. The first a
simply blind copy of the original data and the second used in casting to
match the definition on the PR. For passing by constant reference only the
second (casting) copy will be made. If the passed variable is much larger
than that defined on the PR then the first copy in unnecessarily expensive
as the second (casting) copy would simply truncate the data.

If the variable is an exact match to the PR definition then passing by value
would still involve a complete copy being made, but passing by constant
reference would not because the original would be used and protected from
changes.

Finally, how does %parms work in these cases? I assumed that %parms was
simply a count of the elements in the array of pointers. If the parameters
are passed individually in bound calls then there is no array and no element
count. So is %parms literally the number of parms passed, taking into
account of *OMIT being a passed parm and *NOPASS not? Is this the same for
the PEP too?

Barbara, I would be more than happy for you to correct me on any/all points
above. I genuinely value your advice/help in this.

(At least I can already guess that YES const is much better than value for
long strings :-) )

Cheers

Larry Ducie

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.