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



Alan,
<snip>
I really wish the compiler would implement a CONST_AND_I_MEAN_IT option
i.e. the parm is always passed by copy.
</snip><<

I am confused. I thought that was exactly what VALUE meant.
CONST does not mean I guarantee this value will not be changed. Just that I
will try.


So are you thinking about it in the context of Program to Program calls?
I've never seen a *PGM API use Pass-by-value, (i.e., the VALUE keyword) and I
wouldn't even have considered it to be a possibility. But I suppose it may work.


CONST parms can't be changed by the called subprocedure, unless as Joe explained
there is some subversion going on. But even then, if I recall correctly, there
is in fact a runtime error that will occur if you pull the address-of the const
and try to modify it. OS/400 pointers are very secure.

The stack thing is all academic--it doesn't really occur that way on real
computers like System i. Sure its simulated but at the end of the day, just a
pointer is passed by reference, not the value. Sure some things are put into
registers, but even VALUE parameters are passed by reference under the covers.
(Correctly if I'm wrong about this; if I am, I'm sure someone will.)

The compiler just makes a copy of a pass-by-value parameter value into a work
field that the compiler generates. That field is then passed by reference to the
called subprocedure so that it can be modified without impacting the original
variable's data. Upon return the by-VALUE work field is discarded.

So, having said this, I suppose VALUE could work on program-to-program
calls--but again, I have no need or desire to verify that.



-Bob



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.