3 ms·
How many projects do you see promoting reader macros? The only package I ever used that came with one was CL-SQL, and it was really unpleasant to get everything
by fusiongyro 14y ago
How many projects do you see promoting reader macros? The only package I ever used that came with one was CL-SQL, and it was really unpleasant to get everything working. Reader macros are another example of a feature that Lispers haul out when discussing the benefits of Lisp but never use in practice, because they're almost always more trouble than they're worth.
The reason you perceive this as not terribly useful in practice is my overall point: once you're good enough with Lisp to develop this, you think in terms of s-exps and don't see the point. The primary technical advantage of infix notation is that the book you're getting the formula from used it, so it's easier to see if you transcribed it correctly. A secondary advantage is that it's what you use in your head and on paper. If the advantages of Lisp syntax outweigh the advantages of a lifetime of schooling and compatibility with the world at large, you are, at last, a Lisper. :)
- lispm 14y agoReader macros are there to extend s-expressions. Lisp developers who think in s-expressions use reader macros to implement new data structure syntax (sets, tables, JSON, ...), new code syntax (infix, SQL, Objective-C, ...), ...
- betterunix 14y agoActually 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.