|
"Wilt, Charles" wrote: > > Let me make sure I understand, you said "With const varying > parameters, with or without *VARSIZE: if the passed varying parameter > might have a current length that is longer than the prototyped > parameter, the compiler currently uses a temporary and always assigns > the passed parameter to the temporary." > > So if I've got a procedure defined like so: > d Proc1b pr > d msgData 32768a const varying > > Adding OPTIONS(*VARSIZE) has no effect when passing literals and/or > string expressions, unless what I'm passing is greater than 32768. The sentence you quoted was just regarding passing variables defined with VARYING. When passing literals and expressions, a temporary is always used. With VARYING, the length of the temporary may or may not be the full length of the prototyped parameter. I think it's true that OPTIONS(*VARSIZE) makes no difference with CONST VARYING. Certainly it's logically true - it's impossible to access the part of the variable after the current length, at least with valid RPG coding. So there's no requirement to pass a parameter any longer than necessary. Whether the compiler always takes advantage of that is another question that I can't answer without spending quite a while studying the parameter-passing code. Anyway, trying to optimize compiler temporaries by coding your RPG a particular way is probably a losing proposition. Compiler temporaries are created for more things than just parameter passing. The compiler attempts to reuse temporaries as much as possible; by trying to get it to create a smaller temporary, you might actually cause it to create a new temporary rather than reuse one of the larger size.
As an Amazon Associate we earn from qualifying purchases.
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.