Welcome to davidpratten.com

You can change this text in the options panel in the admin

Member Login

Lost your password?

Reverse Polish Notation Language

January 7, 2009
By david

I love RPN calculators.  My favorite is Hypatia which I use regularly for calculations.  I love being able to order my calculation to avoid brackets and being able to enter a list of numbers and add them up with a single command:

hy 12 23.4 43 94 3 d SUM

Now I am wondering about a full computer language built from the ground up as an RPN language?

A bit of googling led me to RPL or Reverse Polish Lisp which is close.  I wonder if this direction has been explored in other languages.

I am imagining a language where assignment is pretty straight forward (with explanatory pseudocode comment):

1 a = # a = 1

boolean expressions are just regular RPN:

a 1 + b > # a + 1 > b

and an if control structure would look like:

; bf ; bt ; a if # if a then bt else bf;

the meaning of the “;” token is to push following tokens (until the next structural token) unevaluated onto the stack as a single entry.  The if token evaluates the top stack entry (a) and then evaluates either the second (bt) or the third (bf).

A do while loop would look like this:

; b ; a dowhile # do b while a;

The dowhile token evaluates the second stack entry (b) and then the first (a) and repeats until a is false. 

A key of RPN expressions is that there are no brackets required – by analogy in a RPN language there would be no nested statements!

Open question.  Can this idea be developed into a usable programming language?

Tags: ,

One Response to “ Reverse Polish Notation Language ”

  1. [...] I have created Ambi Calculator and Programming Language as a result of investigation about the possibility of a Reverse Polish Notation Language. [...]

Leave a Reply




Rss Feed Tweeter button Facebook button Technorati button Reddit button Myspace button Linkedin button Webonews button Delicious button Digg button Stumbleupon button Newsvine button