|
I see where you are coming from and I agree that this would work, it would just be more coding. It would operate similar to how descriptors work with the IFS and socket API's. There are still a lot of things this model wouldn't allow for, but it still does open up a lot of doors for an instantiation concept. Thanks for your comments Barb, Aaron Bartell -----Original Message----- From: Barbara Morris [mailto:bmorris@ca.ibm.com] Sent: Tuesday, October 01, 2002 9:57 AM To: rpg400-l@midrange.com Subject: Re: Qualified sub-procedures "Bartell, Aaron L. (TC)" wrote: > ... > I'll agree that it kinda works in RPG, but not necessarily a good job. What > if I want to have multiple instantiations of the same object in my program? I had multiple instantiations of the same object in my sample. > > D addr1 s TYPE(ADDRESS) > D addr2 s TYPE(ADDRESS) > > addr1.setCity("Denver") > addr1.setState("CO") > ... > addr2.setCity("Chicago") > addr2.setState("IL") > > and then let's say I want to pass that address into my tax calculation > routine. . . > > tax = calcTax(35.12:addr1) > > Now calcTax will have my addr1 object and all of its functions (getCity, > getState, etc). You can emulate this with data structures, sort of, except > you don't get the functions of the object. > setCity (addr1 : 'Denver') setState (addr1 : 'CO') setCity (addr2 : 'Chicago') setState (addr2 : 'IL') tax = calcTax (35.12 : addr1) Now calcTax will have your addr1 object and all of its functions. If you want each "object" to have a different set of functions, your ADDRESS module needs to have procedure pointers in the ADDRESS data structure, and the setCity etc procedures would call through to the real procedure. Sure, it's a bit more work on the procedure-writing side than using a true OO language, but it's just as easy on the user's side. difference between your version and my version is only a small syntactic difference, "obj.fn(parm)" vs "fn(obj:parm)". Barbara _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com 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.