Styles of syntax used for writing expressions or tree-structured data:


In infix notation you write the operator between the arguments
c - (5 + a + x) * b

Infix notation is the usual. It needs precedence rules and/or brackets to make the order of operations unambiguous. Polish and Reverse Polish don't have that problem, providing the number arguments to each operator is fixed.

Reverse Polish

In Reverse Polish, or postfix, notation you write the operator after the arguments.

c 5 a + x + b * -

It's very easy to interpret expressions in this notation, you need just a single stack to place intermediate values on, this is why Forth and PostScript (which was based on Forth?) use it.


In Polish, or prefix, notation you write the operator before the arguments.

  • c * + 5 + a x b

Polish notation is called that because a famous Polish mathematician first used it for Boolean algebra, and nobody can either remember or pronounce his name without looking it up first. (You go look it up.)


In S-expression, or LISP, notation you write the operator before the arguments, enclosed in brackets
(- c (* (+ 5 a x) b))

LISP operators take any number of arguments so LISP expressions need brackets to associate arguments with operators.

It's very easy to parse this notation into tree structures, which is why LISP uses it.


In XML notation you bracket the arguments with the operator


<variable name="c"/> <multiply>


<constant value="5"/> <variable name="a"/> <variable name="x"/>

</add> <variable name="b"/>



Whoever came up with this had good intentions, I'm sure...