1 + 2However, 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 2Programming 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:
f(x,y)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:
- HP Calculator Simulations
- Forth
- GPS RPN
- Minimal RPN
- RPN again
- Programmable RPN calculator
- Playing bytecode - most minimal, since no space is needed between bytes
- Brute force meets Goedel - discover algorithms in RPN by testing all possibilities
- Pocket Joy 2005
- Numerical RPN
Category Concept | Arts and crafts of Tcl-Tk programming
