Page 1 of 1

Interactive class querying

PostPosted: 23 Nov 2016 16:07
by sotolf
Is it possible to "ask" a class which methods it has? something like:

Code: Select all
ArrayBuffer methods


and it would list to which methods it knows how to answer? Might only work for the methods and not the Properties, but it would come in handy some times when one is working interactively :)

Thank you for all your hard work! :)

Re: Interactive class querying

PostPosted: 23 Nov 2016 20:17
by Franck
Hi,

This word does not exist, but it can be implemented :

Code: Select all
Word method: checkMethods( cl -- )
   self while ( dup notNull ) [
      dup class Method = ifTrue: [
         dup cl implementor dup ifNull: [ drop ] else: [ . dup .cr ]
         ]
      next
      ] drop ;

Class method: methods
   #[ self swap checkMethods ] oforth words apply ;


Franck

Re: Interactive class querying

PostPosted: 24 Nov 2016 09:08
by sotolf
Thank you! Cool, that can come in as practical during interactive programming! :)