nes1983
nes1983

Reputation: 15756

How is "self class" used? / How to query the Pharo image?

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?

Upvotes: 2

Views: 635

Answers (3)

Frank Shearar
Frank Shearar

Reputation: 17132

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.

Upvotes: 3

mathk
mathk

Reputation: 8143

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

Upvotes: 2

Vijay Mathew
Vijay Mathew

Reputation: 27184

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.

Upvotes: 2

Related Questions