Simple Precedence question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple Precedence question

JeffreyStraszheim
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 Straszheim
http://straszheim.50megs.com

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Simple Precedence question

Randal L. Schwartz
>>>>> "Jeffrey" == Jeffrey Straszheim <[hidden email]> 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 - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Simple Precedence question

JeffreyStraszheim
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.

--
Jeffrey Straszheim
http://straszheim.50megs.com

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners