[Newbies] Where is the setter for self?

Ralph Johnson johnson at cs.uiuc.edu
Fri Jun 1 19:55:32 UTC 2012

OK, what do you think the inspector should show on the screen for an
object?  What do you think it should put for "self"?

Would you like some sort of object ID, perhaps its address in memory?

Smalltalk doesn't have a standard object ID that you can access.  It
isn't hard to give each object a unique ID for its class, so that the
objects could print themselves as "Thingee 1" and "Thingee 2".   But
that is up to the programmer.

-Ralph Johnson

On Fri, Jun 1, 2012 at 2:09 PM, Chris Cunnington
<smalltalktelevision at gmail.com> wrote:
> 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
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

More information about the Beginners mailing list