|
Based upon what you are saying here Scot, then does it follow that overloading's only advantage is that we can save some letters? We only need to have one name and it can mean many different things, depending upon the parameters that follow? Much the same as we need to see the surrounding words to know what is meant by the word "type"? --------------------------------------------------------- Booth Martin http://www.MartinVT.com Booth@xxxxxxxxxxxx --------------------------------------------------------- -------Original Message------- From: RPG programming on the AS400 / iSeries Date: Friday, October 17, 2003 5:14:07 PM To: RPG programming on the AS400 / iSeries Subject: Re: Overloading (Was: Please vote for Syntax check in /FREE!) > But then, I would have thought there was a (limited) way of overloading > in RPG: using *OMIT and *NOPASS on the prototype and checking with > %PARMS and the inbound CEE-API's within the procedure. I had been trying to avoid getting involved in this discussion, but I think (based on what I've seen posted here so far) that many people are confused about what overloading is, exactly. I've already stated my opinion on overloading in a past discussion (a month or so ago) and I do not want to bring that up again. All I intend to do here is explain WHAT overloading is. *OMIT and *NOPASS aren't really the same thing. The *OMIT and *NOPASS abilities allow a parameter to be optional. Whereas, overloading really doesn't have any effect on how parameters work -- it just changes the way procedures are looked up. I'll elaborate. When you do a "callp myprocname()" the system looks up the procedure called "myprocname" finds out where it resides in memory, and then runs the code in that location. The thing that overloading changes is how it looks up "myprocname." Instead of just finding a procedure with the NAME "myprocname" it looks for a procedure called "myprocname" with the same parameter types that you've specified on the call. Because the parameter list is also used during this lookup (instead of just the procedure's name) you can have multiple procedures all with the same name, as long as they have different parameter lists. It doesn't change anything else. If you want to have a getMonthName that returns teh month name from a date field, as well as a getMonthName that returns the month name from an integer, you still have to write two procedures. You still have to define two prototypes and two parameter lists, and write two sections of code. The only thing that it changes is that both procedures can now have the same name. If we do not have overloading support, you'd have to call them "getMonthNameFromDate" and "getMonthNameFromInt" because the names have to be unique. So when Joel says: monthname = getMonthName(datefield); and monthname = getMonthName(intfield); he's NOT calling one procedure that can handle either a date or an int. He's calling two different procedures that happen to have the same name. I hope that helps...
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.