|
Lim Hock-Chai wrote:
I didn't want to use varying because I though at run time it will always allocate the max size of the field. Another word, if caller pass only one char to the procedure, at the time, this procedure will still allocate 32767 byte of memory.
The compiler doesn't necessarily do a dynamic allocation of the temporary for each call; it might reuse the same temporary for many different purposes in your procedure. And the compiler uses temporaries for many more things than just parameter passing. Whatever temporaries it needs to convert your parameters might already be available for it to use. Making your procedure so complicated might not be necessary at all. Remember Donald Knuth's words: "Premature optimization is the root of all evil." Anyway, you would likely get much better run-time speed using CONST VARYING; the code to handle the parameter is tons simpler and therefore less error-prone. Having to code %SUBST(parm:1:parmlen) can get pretty annoying. The temptation will be to store it in a varying temporary; might as well let the compiler handle that while passing the parameter.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.