“自学堂”如何?用过的? / 如何查询Pharo图像?

发布于 2024-09-25 09:43:44 字数 212 浏览 2 评论 0原文

调用“self class”有两个主要原因:要么是为了执行用户空间的操作,例如调用静态方法、创建新对象或获取常量。或者是为了反省自己。我很想知道它们各自出现的频率。

查询当前加载的 Pharo 代码库的最佳方法是什么?是否有内置工具,还是我应该使用 SOUL?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

北城半夏 2024-10-02 09:43:44

打开浏览器,转到对象,选择#class并点击“发件人”将显示#class的所有发件人。但这对于回答“它们各自发生的频率”来说并不是很好。

以更易于操作的形式获取相同呼叫站点的方法是使用 Object allCallsOn: #class ,它提供发送者的集合。也许运行一些 #select: 调用来找出一些数字?

或者使用 Refactoring Browser:它有 FinderTool 之类的东西,可以根据 AST 结构进行搜索。

编辑:正如 mathk 指出的那样,有时由于特殊消息或内联消息,senders-of 无法工作。在 vm-dev 列表上有一个有趣的讨论主题。

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.

绳情 2024-10-02 09:43:44

可以帮助您内省系统中任何类/对象的内置工具有:系统浏览器、检查器和对象资源管理器。请参阅Squeak 示例中的“在 Squeak 中进行开发”一章。您在那里找到的信息与 Pharo 相关。

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.

神妖 2024-10-02 09:43:44

Smalltalk中没有静态方法这样的东西。如果你不明白,那你就不明白什么是阶级。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文