I teach computing to 18 year olds. After having reverse polish notation explained to them one asked why is it significant enough to be in the public exam. I explained the historical significance of 70s calculators but this failed to really address the issue. So are there and concurrent practical or theorhetical applications of RPN.
|
|
In computer reverse polish notation is often used in stack-based and concatenative programming languages. It is also common in dataflow and pipeline-based systems, including Unix pipelines.
i.e. top pointer points to
If there are multiple operations, the operator is given immediately after its second operand; so the expression written
|
||||
|
|
|
I've used RPN several times for rapid prototyping, e.g. of programs that have to read and interpret a user-supplied mathematical expression. Whereas regular mathematical notation would require at least a recursive parser (think brackets, operator order, etc...), an RPN parser is basically a stack with a This is, however, usually for rapid prototyping and for convenience. I would never assume that a user can, or wants to, understand RPN. |
||||
|
|
|
Just to expand the previous answers/comments: don't forget that RPN is alive and on great form ... indeed it is currently used in stack machines like the Java virtual machine. From Wikipedia: "... a stack machine implements a stack with registers. The operands of the arithmetic logic unit (ALU) are always the top two registers of the stack and the result from the ALU is stored in the top register of the stack. 'Stack machine' commonly refers to computers which use a Last-in, First-out stack to hold short-lived temporary values while executing individual program statements. The instruction set carries out most ALU actions with postfix (Reverse Polish notation) operations that work only on the expression stack, not on data registers or main memory cells ..." The advantages/disadvantages of such approach are also described in the Wikipedia article. |
|||
|
|
With regards to calculators: See What is RPN?
|
|||
|
|
|
Forth and PostScript (and thus PDF which IIRC started as a binary encoding of a subset of PostScript) are more well known postfix languages that HP pocket calculator one. Then it is also a relatively common choice as intermediate representation in simple compilers. The simpler VM tend to have also a postfix "machine" language. |
|||
|
|