Question

There are two main reasons for calling "self class": Either for doing user-space things such as invoking static methods, creating new objects or obtaining constants. Or for reflecting on one's self. I'd be curios to know how often each of them occurs.

What's the best way to query the currently loaded Pharo code base? Are there built-in tools, or should I use SOUL?

Was it helpful?

Solution

Opening up a Browser, going to Object, selecting #class and hitting "senders" will show you all the senders of #class. That's not great for answering "how often each of them occurs" though.

The way to get the same call sites in a more manipulable form is with Object allCallsOn: #class which gives a collection of senders. Perhaps run some #select: calls to find out some numbers?

Or use the Refactoring Browser: it has things like FinderTool to search based on AST structure.

Edit: As mathk points out, sometimes senders-of won't work, because of special messages or inlined messages. There's an interesting discussion on the vm-dev list on the topic.

OTHER TIPS

The built-in tools that will help you to introspect any class/object in the system are: The System Browser, The Inspector and The Object Explorer. See the chapter "Developing in Squeak" in Squeak by Example. The information you find there is relevant to Pharo.

There is no such thing as static method in smalltalk. If you did not understand that you did not understand what class is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top