Good News Everybody!
The new search engine is LIVE!
Please report any problems to david (at) midrange.com.
|
Am 26.08.2023 um 23:52 schrieb Patrik Schindler <poc@xxxxxxxxxx>:
You typed and formatted/quotes all of that on a miniature screen? :-O
Thanks for your efforts!
If your assumptions are correct, then the actual naming "by value" and "by reference" seem to be misleading to me.
Otherwise, see my answer to Vern. Data is duplicated implicitly before a pointer to the duplicated data is passed to the callee. *Where* it is duplicated, doesn't matter. It is duplicated, and this is the performance penalty price you pay.
Altering parameters that a passed to a procedure is generally „bad style“ - only if passed by reference and with full intention.
Yes, but programming is done by humans and humans make errors. :-) A pass by value could be understood as "safety measure", in this regard.
If a procedure receives a parameter by value and you modify that, this is very convenient - but also confusing.
Maybe I should provide some more context here…
I'm writing programs in old style positional RPG IV, also because I mainly use a very old OS release. I admit, I have not yet looked in depth into "true" functions within one source member. Handling functions seems to me much more cumbersome and noisily (more lines of code) in RPG compared to C. So I usually just use subroutines and necessarily stick to loads of global variables.
<snip>
This means, there is no variable scoping, and inadvertent change of variables within the program flow is a constant source of corner cases to catch.
"Expensive" program functions I put into completely separate applications.
<snip>
In any way, I agree that modifying the memory location being passed to a "secondary" program (by reference) to get output (or error indications) back is bad style. So far I've worked around this by careful designing applications sitting on the call stack being "independent" in error handling and report directly to the user.
In C, retval = dothis() feels very easy.
In classical RPG, probably old enough to when there is no EVAL, I guess messages are involved. A topic I constantly fail to wrap my head around.
Thanks for the hint! Need to look into this, and if it's already available with V4R5.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2026 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.