On Wed, Aug 14, 2024 at 12:45 PM Rony G. Flatscher <[email protected]> wrote:
> The documentation of rexxref.pdf chapter "5.1.4.12. instanceMethods" has a > documentation bug that Josep Maria referred to (# 317, > https://sourceforge.net/p/oorexx/documentation/317/) and supplied a patch > for it. > > Looking into the patch and then into the example that should be working > correctly (ooRexx 5.1.0 in this case), it seems that the method > "instanceMethods" without an argument does not return the complete list of > class methods for the String class. > > Here using instanceMethods on the .class objects involved for the .string > class (.object, .class, .string): > > say .context~name > "(".context~executable~class~id")"saysum=0allMethods1=.bag~newdo clz over > .Class, .Object, .String clzMethods=ppIndexes(clz~instanceMethods(clz)) > items=clzMethods~items > sum+=items > say clz~id":" items "class methods" say clzMethods~makeString(,', ') > allMethods1=allMethods1~union(clzMethods) > say "---" sayendsay "total of:" sumsay "allMethods1~items:" > allMethods1~itemssay "allMethods1:" allMethods1~allIndexes~sort~makeString(, > ', ')saysay "-"~copies(79) > > clzMethods=ppIndexes(.string~instanceMethods) > allMethods2=.bag~new~union(clzMethods)say .string~id":" clzMethods~itemssay > "allMethods2~items:" allMethods2~itemssay clzMethods~makeString(,', ')saysay > "-"~copies(79)saysay "allMethods2:" allMethods2~allIndexes~sort~makeString(, > ', ')saysay "allMethods1~difference(allMethods2):" > allMethods1~difference(allMethods2)~makearray~sort~makeString(, ',')say > "allMethods2~difference(allMethods1):" > allMethods2~difference(allMethods1)~makearray~sort~makeString(, ',') > > ::routine pp > return "["arg(1)"]"::routine ppIndexes > use arg o > arrOut=.array~new > do val over o~allindexes~sort > arrOut~append(pp(val)) > end return arrOut > > Running this program shows at the end the following output: > > allMethods1~difference(allMethods2): [NEW] > allMethods2~difference(allMethods1): > > Indeed there is a NEW method in .Object, one in .Class, and one in > .String, if querying .Object~instanceMethods(.Object), > .Class~instanceMethods(.Class), and .String~instanceMethods(.String), > totalling three NEW methods (they are included in "allMethods1"). > > However .String~instanceMethods only returns two NEW methods (see > "allMethods2") instead of three, hence the discrepancy. > > Why would that be? > The Class NEW method is the method used for new instances of Class objects. The hierarchy is Class~New, Object~New. The String~New method is used for creating new instances of String objects, and like class, the hierarchy is two levels deep (String, Object). You would see the same hierarchy for all classes that are subclasses of Object. The Claas New method would not make any sense in that hierarchy, since Class objects are not getting constructed in that context. Rick > ---rony > > > _______________________________________________ > Oorexx-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/oorexx-devel >
_______________________________________________ Oorexx-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/oorexx-devel
