In this video, I’d like to show you
how we can use the inspector to navigate and
understand the inside of the system.
The inspector is like a microscope
that will enable us to go and explore the inside of
of the system but also, as if we could send probes
to modify the system. It is as if we were
a biologist which is in fact manipulating bacterias and making them react.
So we are gonna have fun exploring what are "Smalltalk globals".
In fact, this is the name space, it is to say, the place where
all Pharo classes are stored.
So it is a dictionary, the system dictionary is
a dictionary. What is interesting is that, with the inspector,
of I look the inspector, it is
a big table with
values inside.
So for example, if I choose… I don’t know…
Breakpoint, I see that in my table I have
a key containing at least an object that contains
this object, that contains a value key.
What is interesting with the inspector is that
here, for instance, I see that at element 2
in the table, what do I have?
I have what we call a global variable.
So a global variable, what is it?
It is an object composed of a key and a value.
The key, if I click on it, I see
that it is a ByteSymbol representing the name, and if
I go backward and I look at the
value, here I will have a class.
So we are going to go inside the classes.
Here I go back to the beginning.
The new Pharo inspector,
named GT Inspector, after the developers
team who developed it for Pharo, will propose
dedicated tabs.
On the system dictionary, what specific tabs
do I have? I have the tab showing the pairs
key/value for my classes,
or I will only get the keys.
The keys are a little less interesting since I
will only have the classes names
in question.
Something nice also is that this
inspector, you see that I can either browse, that means…
let’s take an example…
I have browsed, I go from an object to another by
selecting a path in the structure in question.
If I consider the key for example, if I consider
the value, here I get the class and if on this
class, I go into its methods dictionary…
From the methods dictionary, I could go on a
compiled method etc.
I really browse and with this tool, I can
limit the view of what I want to see or for example view all the flow.
But what is nice, it is that I can also add
a new branch in my flow.
That’s what we are going to do here. So let’s imagine that
I minimize, I go back to the start.
Here finally, let’s imagine I say to myself: “I am
interested by the point class.”
I know that normally I can access
the point class by doing ”Smalltalk global" at #Point.
So here, I do it and I tell it
execute it and open an
inspector in the actual inspector.
And here, all of a sudden, if we look at
the navigation, I made a branching
between the navigation I had and the one I want to go to.
So this is nice, it means that you can type
lots of expressions and begin to the navigation.
So here, what do we see?
We see the point class as an object.
In fact, the inspector shows us
that there are tabs specific to classes.
So here, the “Raw” tab shows
us that the Point class is defined in the
Kernel category, it has an environment, it points on
the same space, this is the encoding format of its
instances, it has a layout.
In short, this is the Pharo implementation of what a class is.
Now, what is really nice with this inspector, it is
that I can see, for example here the definition,
the comments and there are other tabs such as all the references.
So if I click on the reference, here I will see
that Point is really used
in the @ method.
I take a look once more, this is the raw
version of the information which is an object representing
a method and here its Source, so each time I can
choose which is the best
representation for the task I am doing.
So let's go backward.
If I look at
my class, here I would like to go into the methods dictionary.
What is the methods dictionary?
It is a dictionary with a key which is the name of the
method and a value which is a compiled method,
an instance of CompileMethod. So if I looked at the raw
aspect, you see that it is a little more annoying
because I would have to understand how are
implemented the methods dictionaries in order to
interact with them, whereas here it is not what I'm interested in,
I want to look at a compiled method.
So to see a compiled method,
I choose degrees for instance, and I
browse and all of a sudden I get a CompileMethod.
A CompileMethod is an object which, once again,
proposes different ways to be displayed by the inspector.
Here you see a compiled method,
in fact this is a data framework, a table
a little bit specific, it contains Bytecode,
and literals. What are the literals?
In the code, each time you have
asFloat, arcTan, degrees or RadianToDegrees,
it needs to be stored somewhere.
It is stored here, you see, at the beginning
of the compiled method.
What does the Bytecode do?
It refers to those objects
in order to put them in the stack and invoke the methods.
So here, this is what we can see for example, if we look at
the view, I minimize this, if we look at the Bytecode
view, what does it do?
It does PushRcvr, so it puts 0 on the stack and do equal.
What does it correspond to?
If we look a little bit closely,
I display it twice, this display mode is
really very useful, look at what we can do:
if now I want to see
the source, I choose Bytecode there and
and source here, those expressions correspond with each other,
look it is displayed.
So this is great.
It means I can make a push of the receiver instance
variable 0, I put 0 on the stack
and I send the equal message.
And here, it is great because it means
that the person who is making the
compiler can see that the Bytecode he produced
corresponds to the code structure.
In the same way, he can easily
see that... I go backward...
If I am at the top and I click on Self,
here I get my 2 compiled methods.
I get my 2 compiled methods and in fact
I'd like to see if I have
an abstract syntax tree, an increase of abstract
syntax and the source. I can also browse inside.
Here for example, in my tree which can be
complicated for this method, if I open all, I can see
that if I select the temporary
variable Time, I select
the bite of code to which it refers.
This is great too. Once more if
I look at this... The message that sends equal to X
with 0 as an argument, this is this little part of the tree
corresponding to this part here.
The inspector enables me to manage, in the
tree textual representation for example,
the selections I have of the tree nodes.
This constitute a great tool for example to help
people who develop Pharo compiler.
You can find this approach for
each domain, so even for your domain objects
you can extend the inspector,
in order to propose facets and views which make sense.