In this video, I will show you one very nice
facet of Pharo, its inspector.
An inspector is a tool that enables to interact
with objects, and to discuss with them in a lively way.
Let’s try on the file system.
For example, if I do “File system
working directory", I will
get all the files that are, for instance, at my image’s root,
so we will get all those files.
Let’s have a look. If I do “Inspect”,
I open an inspector.
Here I have an inspector.
This is the new Pharo inspector developed
by the GT team, it has
very interesting features.
Let’s begin to look at the tab
called “Raw”.
The “Raw” tab is the old inspector. What will
it show?
It shows the object data, the object instance variables
such as defined in the class.
I can interact with it.
I can, for instance, ask for all the entries.
Here I get all the entries, or give me all the
directories, for instance, here I get all the directories.
If we look at the object class, if I do “self
browse", what do I see?
This view shows me the values
for the object, the instance variables that
have been defined in the class that way.
It enables me to look inside.
For instance, here I can see that the “Path” is actually
composed of this object “self”, and I can see it
here. I am still in raw mode, and
I can browse inside.
If I do this, I am actually going to look at
the User string and that kind of thing.
Here I essentially violate the encapsulation.
The system will look at the introspective behavior,
it will show me the fields values.
This view is very useful.
But now the new inspector does more things.
This means that each object can show to the user
different facets of how it is represented.
By default, every object has the raw facet.
There is also the Meta facet, which is
what enables to browse the class.
We can browse quickly the class, for instance, like this.
Normally, it’s just useful when you are in the navigation
flow, when you need to know directly without opening
another browser.
But the most important are those other tabs.
Here for example,
the inspector knowing that we have a reference,
a directory, shows everything contained in the directory.
It is what I showed you there when I did this.
Here, we get the same thing.
Now, we can browse inside
this file system.
If I choose Ston, this is an equivalent of Json in Pharo,
once more I get a
reference inside the file system, which is
this file here, I get an access on
the file called
meta-inf.ston. And now the inspector is
smart and tells me “I will show you its content if you want.”
I look at its content and it appears I have
a content, I don’t know exactly what it is for, but it is a content.
In the same way, I can browse the sub-folders.
Here, if I choose package-cash, this is the place where
packages are stored by default.
Indeed, this is still an object of the file system
but it shows me its content.
If I look into Data, I can see
one png. If I click on this png, I will browse.
Here, you see there are other tabs.
If I click on Content,
the png as stored in a binary format on my disk.
As it is a png, the inspector shows me a preview
of what the png contains.
If I look at the script.st,
for example, I will have different panes.
Here there are two, I don’t know exactly why
but there is one with syntax highlighting and the other
one without, showing the content once more.
If it is a .zip file, it is even better because when I
on it, the zip content is encoded and
compressed but the items, at this point, are
interpreted. Here I can browse directly
my objects and in the same way recursively.
That was to show you that the Pharo inspector
is really a very powerful tool for interacting
precisely with objects, moreover as each object
determines a representation or a set of
meaningful representations for us to
interact with it and to be the most efficient,
this enables to build very quickly little tools.
Here you have a small file systems browser, why?
Because when you browse and inspect
the file system, sometimes you want to know
exactly what you are inspecting.