title: Could a concatenative language use prefix notation?
body: <p><a href="http://concatenative.org/wiki/view/Concatenative%20language" rel="nofollow noreferrer">Concatenative languages</a> have some very intriguing characteristics, such as being able to compose functions of different arity and being able to factor out any section of a function.  However, many people dismiss them because of their use of postfix notation and how it's tough to read.  Plus the Polish probably don't appreciate people using their carefully crafted notation backwards.</p>
  <p>So, is it possible to have prefix notation?  If it is, what would the tradeoffs be?</p>
  <p>I have an idea of how it could work, but I'm not experienced with concatenative languages so I'm probably missing something.  Basically, a function would be evaluated in reverse order and values would be pulled from the stack in reverse order.  To demonstrate this, I'll compare postfix to what prefix would look like.  Here are some concatenative expressions with the traditional postfix notation.</p>
  <pre><code>5 dup *                             ! Multiply 5 by itself
  3 2 -                               ! Subtract 2 from 3
  (1, 2, 3, 4, 5) [2 &gt;] filter length ! Get the number of integers from 1 to 5
                                      ! that are greater than 2
  </code></pre>
  <p>The expressions are evaluated from left to right: in the first example, <code>5</code> is pushed on the stack, then <code>dup</code> duplicates the top value on the stack, then <code>*</code> multiplies the top two values on the stack.  Functions pull their last argument first from the stack: in the second example, when <code>-</code> is called, <code>2</code> is at the top of the stack, but it is the last argument.</p>
  <p>Here is what I think prefix notation would look like:</p>
  <pre><code>* dup 5
  - 3 2
  length filter (1, 2, 3, 4, 5) [&lt; 2]
  </code></pre>
  <p>The expressions are evaluated from right to left, and functions pull their first argument first from the stack.  Note how the prefix filter example reads much more closely to its description and looks similar to the applicative style.  One issue I noticed is factoring things out might not be as useful.  For example, in postfix notation you can factor out <code>2 -</code> from <code>3 2 -</code> to create a subtractTwo function.  In prefix notation you can factor out <code>- 3</code> from <code>- 3 2</code> to create a subtractFromThree function, which doesn't seem as useful.</p>
  <p>Barring any glaring issues, perhaps a concatenative language that uses prefix notation could win over the people who dislike postfix notation.  Any insight is appreciated.</p>