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")" say sum=0 
allMethods1=.bag~new
   do clzover .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 "---" say end say "total of:" sum
   say "allMethods1~items:" allMethods1~items
   say "allMethods1:" allMethods1~allIndexes~sort~makeString(,', ')
   say say "-"~copies(79)

   clzMethods=ppIndexes(.string~instanceMethods)
   allMethods2=.bag~new~union(clzMethods)
   say .string~id":" clzMethods~items
   say "allMethods2~items:" allMethods2~items
   say clzMethods~makeString(,', ')
   say say "-"~copies(79)
   say say "allMethods2:" allMethods2~allIndexes~sort~makeString(,', ')
   say say "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 valover 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?

---rony

_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to