|
Joe, You're right, it was discussed (I asked the similar question), and i found the best explanation was from Scott Klement , in this reply to my post: http://archive.midrange.com/rpg400-l/200306/msg00510.html most of the best stuff is towards the bottom. There were several other good replies in the thread as well hth, rick "Joe Pluta" <joepluta@xxxxxxxx To: "'RPG programming on the AS400 / iSeries'" <rpg400-l@xxxxxxxxxxxx> thers.com> cc: Sent by: Subject: Value vs. Const rpg400-l-bounces@x idrange.com 08/07/03 03:03 PM Please respond to RPG programming on the AS400 / iSeries Okay, I know the issue was discussed not too long ago, but I'm trying to make sure I understand. I'm going full bore with procedures right now and I'm trying to decide which to use, VALUE or CONST. It's my understanding that either keyword prevents a parameter from being modified by the called procedure. I seem to recall reading that with CONST, not even the local copy can be modified, while with VALUE, the local copy can be modified, but won't be passed back. Thus, a side effect of either keyword is that the compiler can do auto-conversion, converting literals and constants among other things to the correct size (though not performing alpha/numeric conversions). These size conversions are nice in testing, and also for using named constants. My question is whether there is a difference in the actual mechanism of the passing of the parameter. I have to believe that with VALUE, a copy is made of the original variable and this copy is passed. With CONST, I suppose it's possible that a pointer to the original data is passed, and it's up to the compiler to prevent modification. That would be one reason why the compiler flags attempts to modify local parameters declared as CONST, but not those declared as VALUE. The reason I ask is that I'm trying to set up some programming standards. Should I always pass parameters as CONST (except when they are truly going to be modified)? Or are there cases (let's say the data is only 2 bytes long) where it might be more efficient to use VALUE, because only the actual data is being passed on the stack, not a pointer. Joe
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.