|
|
|
|
|
by avhon1
1947 days ago
|
|
This is Polish Notation, and it does not have this problem as long as you don't allow variadic functions. If functions always consume the same number of arguments, it's no problem at all. This is basically how concatenative stack-based languages do it, although by convention they put the arguments before the function call. (Reverse Polish Notation) In Forth, your example would be written one of the following two ways, depending on whether multiply() or sum() is consuming the extra 2: 2 2 2 * 2 + + > 8 2 2 2 * * 2 + > 10 Also valid would be: 2 2 2 * 2 + > 2 6 where the left-most 2 is not consumed, but rather is left in place. |
|