Richard Suchenwirth 2004-02-05 - RPN is short for Reverse Polish Notation. Arithmetics is most frequently done (like Tcl's expr) with infix operators

 1 + 2

However, this gives rise to problems of operator precedence. Jan Lukasiewicz in Poland, early 1900's, devised a way of putting the operator always in front of its operands, which is known as Polish Notation - see Parsing Polish notation:

 + 1 2

Programming languages that employ Polish notation for easier coding are Lisp, Logo, and not least (except for expr arithmetics), Tcl :) Also, in most languages except APL, functions are invoked by giving first the function name and then the arguments, which is Polish:


As you have to visually decode Polish expressions from right to left, which is unusual except in Arabic and Hebrew, the alternative "Reverse Polish Notation" was created [by whom, when?...]]

 1 2 +

This was used in Forth, HP pocket calculators, Postscript and Joy - see Playing Joy. RPN builds heavily on the concept of a stack, and operators pop their arguments, and push their results, to it. So RPN allows to code with no variables at all, which is a desideratum in functional programming - but of course the stack is the Big Variable, changing its value all the time.

Both PN and RPN allow for unparenthesized expressions - mostly because the user has to deliver the very parse tree in advance...

Pages on this Wiki experimenting with RPN in Tcl: