[Newbies] Where is the setter for self?

Bert Freudenberg bert at freudenbergs.de
Fri Jun 1 16:45:09 UTC 2012


On 01.06.2012, at 17:42, Chris Cunnington wrote:

> I'm looking at Lukas's Scriptaculous in Seaside 2.6. He has overwritten #printOn:. A chain of decorations is passed through and at each stage the resulting string is stored in self. This means the usual process of self containing "a SomeObject" instance has been supplanted.
> 
> This is common. If I print:
> 
> 'bob' 'bob'
> 
> A string has been stored in self. I do not get:
> 
> 'bob' a ByteString
> 
> In a walkback I can see ParagraphEditor>>printIt goes to Object>>printStringLimitedTo:. And then a LimitedWriteStream becomes aStream, which is filled with things that somehow go into the pseudo variable self. Hypothetically, like this:
> 
> self setter: aStream
> 
> I imagine the process is somewhere in the march from ParagraphEditor>>printIt to SUObject new.
> 
> Where is the setter for self? How is this stream populating this pseudo variable?
> 
> Any help would be greatly appreciated.
> Thanks,

It's a bit hard to make out what you are actually asking. 

If you implement "printOn:" in any class, then this method determines how instances are printed. 

"self" always refers to the receiver object of the currently executing message. It cannot be stored into.

(LimitedWriteStream on: aString) creates a new stream writing to a string. It inherits "on:" from PositionableStream, which puts aString into the stream's "collection" variable.

The "printOn:" method of an object gets a stream passed as its argument. It then sends messages like "nextPut: something" to the stream, which appends something to its collection.

What else would you like to know?

- Bert -



More information about the Beginners mailing list