[Newbies] Where is the setter for self?

Chris Cunnington smalltalktelevision at gmail.com
Fri Jun 1 19:09:35 UTC 2012


On 12-06-01 1:31 PM, Ralph Johnson wrote:
> Suppose you define a new class Thingee.   If you select "Thingee new"
> and printIt, you will get "a Thingee".
>
> "self" always means "the object that received the message
> that caused this method to be invoked".

I'm confused between the way things look and the way things are.

I can see why you'd find it odd for me to say self could have a setter. 
self is a link, handled behind the scenes, between the instance in 
object memory and a string on the screen. If, when I inspect an 
instance, the self category says "a Thingee" or

"new Control.Slider('handle','track',{onChange:function(){new 
Ajax.Updater('position',null)},sliderValue:null,range:$R(0,100)})"

seems to be immaterial, because all self is doing is holding a thread 
from the screen to the place in object memory.

When a person inspects, the string beside self is the print string. 
Print this instance and this is the string you will get.

In the inspector, the self variable sits beside the print string. I 
think I've found this confusing:

self  "a Thingie"

whereas, this:

self
printString "a Thingie"

might be more explicit, because all I have to do in my mind is this:

self := "a Thingie"

and I think that's what I was doing. Puting the print string beside the 
self pseudo variable is sort of weird to me, as self points to object 
memory; whereas, the print string points to the screen. I find it a 
strange juxtaposition. As near as I can figure it, that was the source 
of my confusion.

Thank you for your help,

Chris





More information about the Beginners mailing list