Interactive class querying

If you have any questions, remarks, ... if you need help... its here...

Interactive class querying

Postby sotolf » 23 Nov 2016 16:07

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! :)
sotolf
 
Posts: 55
Joined: 30 Jul 2015 15:53

Re: Interactive class querying

Postby Franck » 23 Nov 2016 20:17

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
Franck
 
Posts: 148
Joined: 29 Oct 2014 19:01

Re: Interactive class querying

Postby sotolf » 24 Nov 2016 09:08

Thank you! Cool, that can come in as practical during interactive programming! :)
sotolf
 
Posts: 55
Joined: 30 Jul 2015 15:53


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron