Hello everyone, It's probably a silly question but there is something I don't understand in the PharoCommonTools class. There are many methods in this class that i can't find in the image. For example, *PharoCommonTools >> workspaceTool* refers to "*self workspace*" but I can't find any method named workspace in this class or its super classes. And it is the same for all the other tools. What am I missing ? :s Thanks, Matthieu
On 25 May 2015, at 18:27, Matthieu Lacaton <matthieu.lacaton@gmail.com> wrote:
Hello everyone,
It's probably a silly question but there is something I don't understand in the PharoCommonTools class. There are many methods in this class that i can't find in the image.
For example, PharoCommonTools >> workspaceTool refers to "self workspace" but I can't find any method named workspace in this class or its super classes. And it is the same for all the other tools.
What am I missing ? :s
The class PharoCommonTools inherits from ToolRegistry (in other words, ToolRegistry is the parent of PharoCommonTools), which means that all methods from the parent are available in the child as well, as if they were defined there. This is a fundamental concept behind the implementation of Pharo (inheritance, method lookup).
Thanks,
Matthieu
2015-05-25 18:27 GMT+02:00 Matthieu Lacaton <matthieu.lacaton@gmail.com>:
Hello everyone,
It's probably a silly question but there is something I don't understand in the PharoCommonTools class. There are many methods in this class that i can't find in the image.
For example, *PharoCommonTools >> workspaceTool* refers to "*self workspace*" but I can't find any method named workspace in this class or its super classes. And it is the same for all the other tools.
What am I missing ? :s
The super class "ToolRegistry" has a special implementation for method doesNotUnderstand: If it can not understand a message, it looks in its tools registry for a registered tool under that name. Workspace for example registers itself for the key "workspace" and Nautilus for "browser" (Smalltalk tools instVarNamed:#tools ) at:#browser "Nautilus"
Thanks,
Matthieu
Oh yes thx Nicolai, I did not look in the #doesNotUnderstand method. What is the main purpose of doing this instead of actually implementing a method ? 2015-05-25 19:20 GMT+02:00 Nicolai Hess <nicolaihess@web.de>:
2015-05-25 18:27 GMT+02:00 Matthieu Lacaton <matthieu.lacaton@gmail.com>:
Hello everyone,
It's probably a silly question but there is something I don't understand in the PharoCommonTools class. There are many methods in this class that i can't find in the image.
For example, *PharoCommonTools >> workspaceTool* refers to "*self workspace*" but I can't find any method named workspace in this class or its super classes. And it is the same for all the other tools.
What am I missing ? :s
The super class "ToolRegistry" has a special implementation for method doesNotUnderstand: If it can not understand a message, it looks in its tools registry for a registered tool under that name. Workspace for example registers itself for the key "workspace" and Nautilus for "browser"
(Smalltalk tools instVarNamed:#tools ) at:#browser "Nautilus"
Thanks,
Matthieu
On 25 May 2015 at 19:34, Matthieu Lacaton <matthieu.lacaton@gmail.com> wrote:
What is the main purpose of doing this instead of actually implementing a method ?
Being lazy: #doesNotUnderstand is implemented only once, independent of the number of different tools that will be added in the future.
participants (4)
-
Damien Pollet -
Matthieu Lacaton -
Nicolai Hess -
Sven Van Caekenberghe