On 19 November 2013 16:33, gettimothy gettimothy@zoho.com wrote:
Part 4 of the Blue Book--chapter 26 The implementation--in the intro there is this example:
center ^ origin + corner / 2
With these operations
Rectangle center 0 push the value of the receiver's first instance variable (origin) onto the stack 1 push the value of the receiver's second instance variable (corner) onto the stack 176 send a binary message with the selector + 119 push the Smalllnteger 2 onto the stack 185 send a binary message with the selector / 124 return the object on top of the stack as the value of the message (center)
In a Workspace, when I doit on 3 + 7/2 I get 5, left, right, unary, binary....rules apply.
Yep, because "message sending is all there is", which equates here to a lack of operator precedence. So "3 + 7/2" means "(3 + 7) / 2".
+ and / here are known as binary selectors.
What I see here--and please check my reasoning--is a RPN that places things onto the stack via Smalltalk's order of operation rules and then does conventional RPN processing.
More generally, keyword sends take precedence over unary sends which take precedence over binary selectors. So in
foo something: 1 + 2 negated with: bar
the #negated message will be sent to the object 2, that will be the argument of the #+ message, sent to the object 1, and then that result and the object bar will be the arguments of the #something:with: message to the foo object.
frank
In other words, Smalltalk expressions are translated to RPN and then placed on the stack.
A simple 'banish the thought' or 'yep' or 'sometimes' would be helpful as I move forward in my study. I am just trying to avoid carrying forward an improper idea that I will have to revise later when/if the facts turn out otherwise.
thx.
t