Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am afraid I didn't understand most of the sentence. I am not familiar with the notation you are referring to, not the type of expression you mean :(


Infix notation is when the operators goes in the middle. For instance, the expression: x * (y-z) uses infix notation. When I look at it, I can see at a glance that x is multiplied by the difference between y and z. However, were I to listen to it, I wouldn't know when to expect the parenthesis to close. I would have to remember that I am within a parenthesis.

Postfix notation, or reverse polish notation places operators after the operands. So that same expression would read " x y z - * ". The idea is that you push x on a stack, then y, then z. Then comes the minus sign, you pop the top two elements, y and z, and push their difference on the stack. Finally you pop the two elements, x and y-z, and replace them with their product.

In reverse polish notation, you still need to remember something, the state of the stack, but there are no parenthesis. I get the impression it would easier to parse if listening to the expression, but I may be wrong.

So which parses most easily for you? x * (y-z), or x y z - * ?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: