Postfix

The parameter stack implies postfix. Postfix follows from transferring parameters on a stack.

Operational notation

Postfix notes how it is done, it is operational notation that describes how the operation is performed. Infix notation must be converted by the compiler for execution on the machine. Infix feels familiar because we are trained in infix. However, we and the CPU evaluate the expression in postfix.

Simple programming language

- No intermediate variables needed to transfer arguments
- No block markers needed
- Flow control ranges are delimited by meaningful words
- No statement delimiters, continuous flow of action.
- Definition sequence = execution sequence, easy tracing with single stepping
- Arithmetic operations are clear, no parentheses, no priorities

Formal notation has a price: Complexity

You know the result of 2+3, now what is 2+3*4 ? No problem either, but note that you need an additional rule, the rule of precedence of arithmetic operators. And so does the compiler. Or you could use parentheses (another rule for you and the compiler) to specify (2+3)*4.

In postfix notation no additional rules are needed. You write 2 3 4 * + or 2 3 + 4 * .

The complexity of infix notation is easily handled even in simple calculators, so why worry?

Because this is a fundamental problem in software engineering. Each new level of formalism breeds new complexity. For you and for the compiler or interpreter.

For example: Infix Tcl is described by 12 rules. Infix looks elegant, but it has a price: If Tcl would use postfix (if procs would transfer parameters on a stack), 6 of the rules would be obsolete.

This does not claim that a postfix program is easier to read and understand. I think it is, but that's really a personal matter. I include the source of postfix Chess in Forth for comparison with the infix version Chess in Tcl.

Postfix simplifies the compiler

A program written in postfix can be converted directly into executable code. A formal program written in functional notation must first be converted (scanned and parsed, lexically analysed) into an intermediate form that is then converted to executable code. One widely used intermediate code form is postfix notation.

In other words, compilers first convert the formal program into the notation that Forth uses naturally. Forth programmers work on the intermediate compiler level.

I don't claim that Forth is better, I say Forth is simpler. If you are taking "KISS" really serious, you ought to consider Forth. It reduces complexity.

Postfix is natural is how we act in real life

Some people claim that postfix is weird. I note that postfix is the common way of life. In real life I usually pick the operands before doing the action. Say, to write a postcard: I grab the card and grab the pen (operands) then I write (operation). I suppose so do you.