[Reasons why I use an RPN calculator snipped]
I'm intrigued. I don't understand, but
that's OK.
What don;'t you understand ? RPN, or why I prefer to use it?
For the former, I assume you are happy with the ideal of a stack. You
read an RPN expression left to right. When you come to a number, push it
onto the stack. One-argument functions (SIN, SQRT, etc) take the number
of the top of stack, perforem the operation on it, and push the result
(so the sizxe of the stack is unchanged). Two-argument fucntions take 2
numbers off the stack, combine them, and push the result (so the stack is
reduced in size by oen item).
Some RPN-based languages and machines allow you to push other things onto
th stack (strings, expressions, complex numbers, arrays, etc) and have
functions that take more than 2 arguments and, indeed return more htan
one reuslt. But the rules are the same. Data is pushed onto the stack,
functions thak the arguemtns they need (and remove them from the stack)
and push the reuslt.
And that's really all there is to RPN.
As to why I like it, I prefer tools (in the genral sense) that willalways
do what I expect. I want to think about the problem I am trying to solve,
not have to worry about what the calcualtor (or whatever) is going to do.
RPN has 2 main advntages here. The first is that the above rules are all
you need. There are no rules of heirarchy. no brackets, nothing like
that. FUcntions are evaluated as you come to them rreading the expresion.
I don't ahve to think about what the machine is goign to do.
The second is that it's very easy to 'chain' calculations together,
partuclarly on a machine with an arbitrarily large stack (such as HP's
RPL calcualtors). For example I can do things like :
4700 2200 + 10000 + (That's the total resistanec of a 4.7k, 2.2k and 10k
resiutor in series)
3300 3900 + (that's a 3.3k and a 3.9k in series), not that the previous
result is not cleared, it's sitting in the sxcond stack level
INV SWAP INV + INV (where INV is the reciprocal function, and SWAP
exchanges the top 2 stack levels) to work out what the resistance of
those 2 resistor chains in parallel is.
It's possible to do that sort of thing on some infix calculators, but uou
normally have to plan it out rather more, store results in a memory
register by hand, etc. RPN does that sort of thing automatcially.
RPN is, I suppose rather differnt to many modern computer products. The
latter seem to be designed to make simple problems trivial, but
unfortunately, they make complex problems very difficult or impossible.
RPN (and in gnerally the tools I prefer) makes simple problems pehaps a
little more dififcult (but is it really harder to type 2 2 + rahter than
2 + 2?) but make dififuclt problems a lot easier. Since generally I sue
calcualtors and computers for difficult problems that I can't solve in my
head, I prefer such tools.
-tony