PharoCommonTools methods

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PharoCommonTools methods

Matthieu
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
Reply | Threaded
Open this post in threaded view
|

Re: PharoCommonTools methods

Sven Van Caekenberghe-2

> On 25 May 2015, at 18:27, Matthieu Lacaton <[hidden email]> 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


Reply | Threaded
Open this post in threaded view
|

Re: PharoCommonTools methods

Nicolai Hess
In reply to this post by Matthieu


2015-05-25 18:27 GMT+02:00 Matthieu Lacaton <[hidden email]>:
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

Reply | Threaded
Open this post in threaded view
|

Re: PharoCommonTools methods

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 <[hidden email]>:


2015-05-25 18:27 GMT+02:00 Matthieu Lacaton <[hidden email]>:
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


Reply | Threaded
Open this post in threaded view
|

Re: PharoCommonTools methods

Damien Pollet-2
On 25 May 2015 at 19:34, Matthieu Lacaton <[hidden email]> 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.