On 15.08.2024 15:38, Rick McGuire wrote:

On Thu, Aug 15, 2024 at 8:05 AM Rony G. Flatscher <rony.flatsc...@wu.ac.at> 
wrote:


... cut ...

I'm not seeing anything that appears to be missing from .String~instancemethods, so I'm not seeing any problem here.

Oops, you are right, there was a coding error (corrected code below)!


There is certainly one error in your assumptions. You are assuming that any class object will automatically have all of the methods of .Class, but other class objects do not directly inherit from  .Class, but are instances created by .Class (or rather the metaclass, which is .Class in most cases).

Yes, indeed, metcalasses, would need to be taken into account for a general test (and if so, their superclasses up to and including .class would need to be processed)!


That new class object does not automatically get all of the methods of the metaclass, for example, the NEW methods.

This is an important information, as NEW is treated then as a special case at class object construction time. Would that also mean that it is not possible to invoke "self~new:super"?


In that state, it is barely usable. The full scope of the instance methods is then built up by adding in the inheritance hierarchy. So, if you are manually trying to construct things yourself, you would do this by adding the instance methods from each superclass, ending with adding in .Object~instancemethods(.Class).

Thank you for all of your explanations!

---rony


P.S.: Just for the record the corrected code:

   call testInstanceMethods.string say "="~copies(79)
   say call testInstanceMethods"hello world"

   ::routine testInstanceMethods
      use arg obj
      bIsClassObject=obj~isA(.class)
      if bIsClassObjectthen clz=obj
                        else clz=obj~class

      say "instanceMethods of" pp(obj)":" superclasses=clz~superClasses-- get array of superclasses 
say "=============" say "superclasses:" ppDoOver(superclasses)~makeString(,', ')
      say "=============" say "clz~metclass:" clz~metaclass
      say sum=0 arrMeths=.array~new
      classes2ask= .array~of(clz)~~appendAll(superclasses)
      if bIsClassObjectthen classes2ask~append(.class)-- we have also the 
methods of .class available do oover classes2ask
         tmpObj=bIsClassObject~?(o,obj)
         
arrOMeths=ppDoOver(.array~new~appendall(tmpObj~instanceMethods(o)~allIndexes~sort))
         arrMeths~appendAll(arrOMeths)
         sum+=arrOMeths~items
         say "---> " pp(tmpObj)"~instanceMethods("pp(o)"), arrOMeths~items:" 
pp(arrOMeths~items)", methods:" if arrOMeths~items>0 then say " " arrOMeths~makeString(,', ')
         say end say say "arrMeths~items:" arrMeths~items"sum:" sum
      say "-"~copies(79)
      say tmpObj=bIsClassObject~?(clz,obj)
      say "allMeths, result of:" pp(tmpObj)"~instanceMethods:" 
allMeths=ppDoOver(tmpObj~instanceMethods~allIndexes~sort)
      say "allMeths~items:" allMeths~items
      say "===> allMeths:"allMeths~makeString(,', ')
      say "allMeths~items:" allMeths~items
      say

   ::routine pp
      return "["arg(1)"]" ::routine ppDoOver
      use arg o
      arrOut=.array~new
      do valover o
         arrOut~append(pp(val))
      end return arrOut
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to