| Postfix isn't hard to understand. Postifix with no syntactic delimitation is hard to understand. The problem with Forth is that although we undersatnd what each word does in isolation, when we look at a word in the middle of the program, we do not have an instant idea about what material to the left of the word produces its arguments and how, and what material to the right consumes its result. We have to go back and simulate the stack machine in our mind to work this out. What does this do? w1 w2 w3 w4? We have to know what w1 through w4 do to understand how their data flows are connected together! That's just wrong. In any sane language, we don't have to know what w4 exactly does in order to understand that, for instance, takes two inputs produced by w1 through w3. The above words could be totally independent from each other, and produce four operands on the stack. Or it could be that they thread a value through them: each one transforms the top word on the stack. The expressions in a nice, nested, functional notation give us the functional tree at a glance. We can achieve this while keeping the notation postfix, by adding parentheses: (w1 w2 w3)w4
Now w4 is a three-argument function. w1 through w3 take no arguments. ((w1)w2 w3)w4
Now w1 produces the argument value for w2. This is the left argument of w4, and w3 is the right argument.Moreover, now we can reason about different evaluation orders, as long as we know there are no side effects. I can think about w3 and then w2 and w1, or vice versa. Moreover, if w4 is declared as requiring exactly one argument, the error is now statically obvious. |