4 ms·
Actually I stopped seeing the point of infix notation long before I started programming in Lisp; infix notation stopped seeming like the cat's meow when I had t
by betterunix 14y ago
Actually I stopped seeing the point of infix notation long before I started programming in Lisp; infix notation stopped seeming like the cat's meow when I had to actually spend time thinking about how to parse it. I have yet to encounter a good argument for infix notation; all anyone seems to offer is, "Well it's what everyone knows and what we teach in schools!" I am not even sure that infix notation being taught in schools should be pointed to as a positive thing, given that "Please Excuse My Dear Aunt Sally" does nothing to improve anyone's understanding of math (when was the last time you saw PEMDAS written in a proof?). I'm sure there would be endless complaints from parents who were unable to help their children with their arithmetic homework if we suddenly switched to postfix notation in elementary school.
I don't think mindlessly transcribing formulas from textbooks is a strong argument for infix notation, and it is definitely not a technical advantage. I am not entirely sure that infix is what people naturally use internally, either, as it is not unusual to hear people say things like, "subtract 3 from x" or "divide the sum of the numbers by the count" -- those look more like something you would see in Lisp than infix notation to me.
- fusiongyro 14y agoThis is one of those debates where there's no convincing anyone on either side. Convention is the only argument I have or need, and it's perfectly sufficient for me. It's insufficient for you and the rest of the Lisp world. This has been the state of affairs for the last fifty years and it will continue to be the state of affairs until the end of time.
- marcosdumay 14y agoInfix notation is compact. That makes it better for parsing by humans with limited short term memory.
- nnq 14y agoI think it's more about pushing you mind towards a more imperative and sequential way of thinking than compactness (see my comment above)... but this shouldn't be "anti-Lisp" since Lisps have always tried to be "multi-paradigm"...
- fusiongyro 14y agoFor what it's worth, I'm not trying to be anti-Lisp with my remarks. I'm just trying to point out that this particular widely-cited example of a macro is false advertising.
- nnq 14y agoI hope you mean prefix not postfix. Postfix (or Reverse Polish Notation http://en.wikipedia.org/wiki/Reverse_Polish_notation http://en.wikipedia.org/wiki/Reverse_Polish_notation) is completely "unintuitive" for both mathematicians and laymen, and I wouldn't wanna see it in any school... maybe for speakers of RTL languages like arabic it looks more natural, but... no
- tverlinden 14y agoTry telling that to a Forth programmer. ;) But seriously, now. Reverse Polish notation is plenty intuitive as long as you don't get too crazy with what you put on the stack. For example, (7**3 + 9*7) / 2 might be rendered: 7 3 ** 9 7 * + 2 / That is, "Take 7 and 3 and exponentiate, take 9 and 7 and multiply, then add the two numbers, take the answer and 2 and divide." Parentheses or extra spacing could easily be used to increase readability (though parentheses are never required in RPN; they're purely aesthetic), if that's too much to swallow: (((7 3 **) (9 7 *) +) 2 /) ...But really it's just a matter of what you're used to. P.S. You'll notice that with parentheses RPN looked remarkably Lisp-like. This isn't a coincidence. The core difference between prefix notation as used by Lisp and RPN is that operators in RPN may only take two arguments (it's more complicated in languages like Forth, but since we're talking about arithmetic here we can safely make this assertion). This is the tradeoff RPN makes: losing the ability to have n number of arguments per operator, for the ability to ditch those parentheses for good. It should also be clear that one could easily have a Lisp-like syntax similar in appearance to the RPN with parentheses above (though with Lisp's ability to have more than two arguments), but just happening to put operators at the end. Conversely, one could have an RPN where operators are at the front, which is actually the concept behind Polish notation, where RPN stems from: http://en.wikipedia.org/wiki/Polish_notation http://en.wikipedia.org/wiki/Polish_notation On a final note, since RPN is read from left-to-right exclusively, a speaker of an RTL language would actually be worse off. The perceived unintuitiveness is more because English is a subject-verb-object language, whereas RPN is subject-object-verb.
- nnq 14y agonever had experience with Forth or anyth similar, so thanks for clearing. and the fact that fixed arity for an operator or function makes parentheses unnecessary is cool... never thought of that before :)