So, I'm learning Smalltalk for the first time, and I have a very simple question regarding the precedence of the cascade operator.
So, in this expression:
self something: anObject selector ; anotherSelector.
Is the target of *anotherSelector* anObject, or self?
In other words, does it parse like this
self something: (anObject selector ; anotherSelector).
or
self something: (anObject selector) ; anotherSelector.
Also, what is the general principle that determines this.
Thanks in advance.
"Jeffrey" == Jeffrey Straszheim jstraszheim@comcast.net writes:
Jeffrey> So, I'm learning Smalltalk for the first time, and I have a very Jeffrey> simple question regarding the precedence of the cascade operator.
Jeffrey> So, in this expression:
Jeffrey> self something: anObject selector ; anotherSelector.
Jeffrey> Is the target of *anotherSelector* anObject, or self?
The way to read ";" is that you're replacing the last message send of what precedes it with what follows it. So let's see the order there:
t1 := anObject selector. t2 := self something: t1.
That should make sense. Now for the cascade... we do another message send to whatever the most recent *receiver* was. In this case, "self":
t3 := self anotherSelector.
And the overall value would be t3, if anyone looked at it.
Randal L. Schwartz wrote:
... Now for the cascade... we do another message send to whatever the most recent *receiver* was ...
Thanks. That makes perfect sense.
beginners@lists.squeakfoundation.org