Deal of the Month: 50% Discount on Windows 7 (Limited Amazon.com offer) Main Page | Report this Page
Computers Forum Index  »  Computer Languages (Smalltalk)  »  Why doesn't smalltalk use RPN?
Page 1 of 1    

Why doesn't smalltalk use RPN?

Author Message
Guest
Posted: Sat Jun 24, 2006 1:31 am
I just installed gnu smalltalk and i'm going through the tutorial (I
gave up on squeak for the time being as the multimedia is being a
distraction). One thing strikes me is that though it's somewhat like
forth in that a noun precedes a verb (postfix syntax), the mathematical
operations are algebraec infix. I find this jarring. It's somewhat like
tcl, which has a lisplike prefix syntax but uses algebraec infix for
math.

I wish smalltalk used RPN for it all to be consistent. 3 4 + would've
been 3 4 as objects and send a + message to them.
 
Bruce Badger
Posted: Sat Jun 24, 2006 2:28 am
Guest
On Fri, 23 Jun 2006 14:31:55 -0700, casioculture wrote:

Quote:
I wish smalltalk used RPN for it all to be consistent. 3 4 + would've
been 3 4 as objects and send a + message to them.

There is no spoon, er sorry, there is no operator. There are only
messages sent to objects.

every message is sent to a single receiver.

A message is made up of a selector and arguments (zero args for a unary
message).

In your example you want two objects to be the receiver. In this case,
which + method should be used? The one for 3 or the one for 4? This is
made more obvious with something like:

(SumOfMoney for: aBalance in: #EUR) 4 +

Should the + for the SumOfMoney be executed, or the + for 4?

Smalltalk syntax (what little there is) supports the message passing idea.
RPN (as nice as it is) is jarring in that context.

All the best,
Bruce
 
Guest
Posted: Sat Jun 24, 2006 6:31 am
casioculture@gmail.com wrote:
Quote:
... forth in that a noun precedes a verb (postfix syntax), the mathematical
operations are algebraec infix. I find this jarring. It's somewhat like
tcl, which has a lisplike prefix syntax but uses algebraec infix for
math.

I wish smalltalk used RPN for it all to be consistent. 3 4 + would've
been 3 4 as objects and send a + message to them.

Hello - I found some of the syntax 'jarring' also, until I realized the
consistancy of
object (noun-like) followed by message (verb-like). The '3', and
instance of Integer Class (an object) is being sent the message, '+',
with the parameter '4', which is also an instance of Integer Class
(another object). Perhaps, it might be better to think: '3 add: 4'
which returns the result of '3' with the message 'add:' with the
argument '4', which would be '7', also an instance of Integer Class.
RPN only made sense to me when I visualized a '3' and '4' pushed to a
stack, the
seeing a '+' operator, it popped the top two elements (fetch), did the
operation (add) and pushed (store) the result back on the stack.
Smalltalk did not encourage or discourage my visualizing a 'stack'.
That is, I did not have to care about the implementation of the message
'+'. But if I cared, I could look it up.
Hope this helps,
ACG
 
 
Page 1 of 1    
All times are GMT
The time now is Sun Nov 08, 2009 4:18 am