instance side

Herbert König herbertkoenig at gmx.net
Thu Nov 30 19:03:44 UTC 2006


Hello Julian,

JD> Could some one explain what “instance side”means? And please
JD> keep this as basic as you can, thanks,

in object land (Smalltalk) programs are messages sent to objects.

Objects are instances of classes.

So if a message is meant to go to an instance of a class (big
majority) it is defined on the instance side of the class. If it goes
to the class itself it is defined on the class side.

If you open a browser, select any class, you will find two buttons
below the class pane, one named instance, one named class which will
show you two sets of methods one set defined on the instance side the
other set of methods defined on the class side. The latter are usually
much fewer than the first.

Something to enter and doIt in a Workspace, remember messages to
instances are defined on the instance side, messages to classes are
sent to the class side:

myRectangle := Morph new
"here the new message goes to the class Morph to create a new
instance, which can be referred to through the variable myMorph"

myRectangle openInWorld
"the instance is sent the message openInWorld, you will see a blue
rectangle top left of Squeak's Window"

myRectangle color: (Color green)

"This is a combination: The instance is sent the message color: which
needs a parameter, the expression in the (unnecessary) brackets.
This parameter is created by sending the message green to the Class
Color.
So in a Browser find Class Morph, on the instance side you will find
the message color: and if you find Class Color you will find the
message green on the class side"

hth

Herbert                            mailto:herbertkoenig at gmx.net




More information about the Squeak-dev mailing list