3 ms·
Yeah, I agree, it's just about as easy to compute Lisp arithmetic as infix arithmetic. The problem, for me, is that it's not as easy to understand, read, or wr
by devinj 16y ago
Yeah, I agree, it's just about as easy to compute Lisp arithmetic as infix arithmetic.
The problem, for me, is that it's not as easy to understand, read, or write. By this, I mean that most of the time that I'm reading an arithmetical expression, I don't really care what it means. I am only reading it because it's easier to just read it than to look for where it ends and continue. It's fluff. Not being as comfortable with prefix, and probably never being as comfortable with infix, it's not as friendly to the eyes.
When I need to understand it, I'm basically converting to infix-- I think in infix, not prefix. The parentheses in the infix expression are mental and implicit, and I think my mental notation is more than adequate. Prefix form gets in the way here.
And obviously, it's more of a pain to write fully parenthesized arithmetic than not.
- MikeTaylor 16y agoYes, 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 16y 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 16y 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 16y 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 16y 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 16y 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