|
On Dec 15, 2016, at 3:36 PM, Mark Murphy/STAR BASE Consulting Inc. <mmurphy@xxxxxxxxxxxxxxx> wrote:
I added a new RFE to add procedure templates to RPG. Here is my justification:
When creating a prototype that references a procedure via Procedure pointer the prototype can not be used on both the caller and the callee side of the call. The caller needs a procedure pointer in the ExtProc keyword, and it must be in the same scope as the pointer or you will get compile errors. If you try to use the same prototype in the module with the procedure interface, the pointer does not exist, and you have compile issues. So when using procedure pointers, you have to have multiple definitions of the same prototype which introduces the opportunity for errors and mismatches. It would be nice if I could define a procedure template for these situations. The template could sit in the copybook containing my other prototypes, and then I could define local prototypes as necessary against it with something LikeProc. Or they could opt to remove ExtProc from the prototype or allow some sort of local override by defining a local prototype LikePR and allowing that prototype to
have the ExtProc with the procedure pointer. Now that I am thinking about it, that is probably the best option so a plain prototype sits in my copy book to be used by procedure interfaces or calls that do not need a procedure pointer, and a prototype that needs a procedure pointer is defined with LikePR and allows ExtProc() with a procedure pointer.
Why use procedure pointers in the first place? They are the key to the callback pattern. Since functions aren't first class objects in RPG, I need to pass a procedure pointer instead of a procedure if I want an abstraction that needs some local help in the form of a callback.
http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=98662
Mark Murphy
Atlas Data Systems
mmurphy@xxxxxxxxxxxxxxx
--
This is the RPG programming on the IBM i (AS/400 and 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.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD
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.