Hi, Joe,
If you really want to emulate something like the kind of "polymorphism" that Java supports, you could actually accomplish this by writing a pre-processor for the ILE RPG IV language. (This is also actually supported by several ILE preprocessor APIs.)
Then, rather than having to invent unique names for each unique "variation" you could just translate the input source (the function invocation) at "pre-compile time" to call your "common function" that implements the desired functionality, with the appropriate number of *OMITs inserted in all the right places. Once you reach the point where the %parms can detect the absence of the remaining parameters, you can just emit the closing ")".
Let me know if you are interested in pursuing that possibility, and I can supply you with some working sample code. :)
If you need to add some "introspection" capabilities, I can also give you some ideas about how to accomplish that, also using a combination of some existing and newer ILE APIs to add your own data to the compiled *MODULEs, that can be retrieved by the programs at runtime to learn more about themselves. ;-)
All the best,
Mark S. Waterbury
On Tuesday, April 2, 2019, 4:57:22 PM EDT, Joe Pluta <joepluta@xxxxxxxxxxxxxxxxx> wrote:
Yes, that's in essence what I'm doing. And I have no problem creating a
convenience procedure for each basic combination. The problem is the
large number of parameters at the end. If you have three, it's not
bad. When you have 5, or 7, or 9, the number of convenience functions
gets ugly, especially since you have to give each one a separate name.
With everyone's input, though, I think I'm closing in on a solution.
On 4/2/2019 3:53 PM, Alan Campin wrote:
Looking at this I think what are looking at is Polymorphism. The ability of
Java or other languages to based on the type of parameters to know which
procedure to call . RPG doesn't have it.
That would seem to me if that is true you really only have a couple of
options. Write a function for each type. Not really that big of a deal or
do like you are doing of having one procedure that passes a constant type
and the address of a variable and then you function figures out which value
got called and call the proper function to call.
i think just have a single function for each type would be simpler.
As an Amazon Associate we earn from qualifying purchases.