|
I prefer to use CONST unless I know that the called procedure needs to pass the value along to another proc/pgm where it could be modified; then I use VALUE. If the called proc needs to modify the value, that VALUE is you're only choice. Of course if you don't want the benefits of VALUE and CONST, (casting data to the desired form) then you don't use either. Bob Cozzi Cozzi Consulting www.rpgiv.com -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Joe Pluta Sent: Thursday, August 07, 2003 3:04 PM To: 'RPG programming on the AS400 / iSeries' Subject: Value vs. Const 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 _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
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.