3 ms·
Yes, devinj, that's it exactly. Lisp notation does win in the cases where you want to sum (or multiply) a bunch of numbers in a single shot, as in (+ 42 53 12
by MikeTaylor 17y ago
Yes, devinj, that's it exactly. Lisp notation does win in the cases where you want to sum (or multiply) a bunch of numbers in a single shot, as in (+ 42 53 12 999); but otherwise, the requirement of full bracketing, and the removal of operands from their operators, and the need to COUNT parentheses to see what goes with what, make the notation clumsy. Sorry, Lispers, it's true.
(+ (* (- (/ 45 99) (* (+ 1 4) 3)) (* 4 (- 5 3))))
Which operator operates on the result of the 4*(5-3) sub-expression? You have to stop and THINK about that -- you can't just SEE the answer.
- weavejester 17y agoBut as pavelludiq points out, you don't ever write math in Lisp like that. I'd write it: (+ (* (- (/ 45 99) (* 3 (+ 1 4))) (* 4 (- 5 3)))) Or perhaps add in even more indentation. In any case, now if you asked me what operates on the result of (* 4 (- 5 3)), I could tell you immediately that it's *. That said, I do agree that infix notation for mathematics can often be clearer and more concise. If I found myself doing a lot of arithmetic, I might be tempted to write a macro to allow me to write in infix.
- MikeTaylor 17y agoPaul Graham is often saying that the value of Lisp is in large part due to its being so concise. If we have to throw away four lines every time we have a moderately complex arithmetic expression, we're losing quality. ... none of which is to say that Lisp Is Bad (which is certainly not the point I was trying to make in the original article) -- just that the good points are to some degree balanced by some bad ones, and Lisp evangelists don't ultimately help their cause by pretending that even the bad bits are good.
- pavelludiq 17y agoThere is nothing stopping you from writing gigantic one-liners in lisp, thats not the same as conciseness. Anyway, my point was that arithmetic doesn't mater that much, if you like the lisp notation, thats fine, if you hate it, you can at least manage it with proper indentation. Its a minuscule annoyance for me.
- JeanPierre 17y agoEven if you do, mathematics in LISP is not looking pretty, or "normal" in the beginning for the newcomer. However, as you start using LISP more and more frequently, the expression you gave could be evaluated within your head at sight. It's just to know where to start looking for a opening/closing paren.
- lispm 17y agoif that is really a huge problem for you, then you can use Infix readmacros for arithmetic expressions. Something like this: http://www.cliki.net/infix