开发者

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

There are two main开发者_StackOverflow社区 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜