|
When I need to update more than one value, I just return a data structure from the procedure. That way I can return as many fields as I need to. Ross Hartford Cothern Computer Systems, Inc. 1640 Lelia Drive, Suite 200 Jackson, MS 39216 Phone: 601-718-0803 Fax: 601-969-1184 Support: 888-222-5577 email: rossh@xxxxxxxxxxx website: www.ccslink.com -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Joe Pluta Sent: Thursday, July 28, 2005 8:39 AM To: 'RPG programming on the AS400 / iSeries' Subject: RE: No Subroutines (was Re: Debugging many subprocedures) > From: Joe Pluta > > Sorry, I misread your post; you're getting to use /free. Good luck, > it's actually quite fun, and the extra space makes the argument for > procedures a bit stronger. BTW, here's an observation: one of the problems with functions in most other languages is that there is only one return value. This has always been a stupid limitation in my opinion. I'd prefer a syntax like "return (rc, message)". You could even have message optional and returned as null if not specified, but that requires multiple exit points in a procedure which can be troublesome. But I digress. Because while the same is nominally true for RPG, it is easy to have input/output parameters of any type (in fact, this is the default). And so in fact I can support error messages. I can even support the concept of catchable vs. throwable messages; by putting optional error message fields at the end of the parameter block, I can specify whether the caller wants to handle the error or wants it to raise an exception. However, the ability of a procedure to modify a parameter (which is strictly speaking a side effect) is a problem with a lot of programmers. Personally, it's pretty ingrained in me to no have update-capable parameters, although I do bend the rules occasionally. How about you? Do you use update capable parameters? If so, is there a way (other than the prototype itself, obviously) that you make sure the caller knows that a given field is changed by the procedure? The reason I say other than the prototype is because there are performance considerations when using VALUE and CONST. I'm just wondering how often people use bidirectional parms, and how they keep it straight. It would seem to me that this could be a possibility for nightmarish bugs. Imagine somebody changing a pointer parameter? 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.