Earlier quoted context omitted.
To whom did 'functional' mean the same thing as 'lisp'? I'm always astonished when people conflate these two things. Lisp encourages you to put the forms that evaluate to a value in the position you would otherwise put a variable that has been set to that value, sortof code in place. That is kindof like functional programming. However, lisp does not avoid side effects or mutability, in fact virtually all operators in…
That's an interesting point about infix and postfix calculators but no prefix calculators. Though I wouldn't go so far to say there aren't any, I feel pretty sure I've seen one before--though don't care enough to go looking--they do seem pretty rare. I wonder what lisp/scheme/whatever-I-need-to-say-to-get-you-to-stop-being-pedantic would look like with post-fix evaluation.
Infix is easier to read, because it is just more natural to parse. An expression like:
sin(1 + (5 + x + y) / (n + k)) is just really easy to understand
(sin (+ 1 (/ (+ 5 x y) (+ n k))) is inscrutable, at least to me.
The second thing is, intermediate variables makes code much more readable, but lisp strongly discourages this. The only way to create a lexical variable is with LET. But this causes indenting, which is pretty ugly. In fact, the use of indenting for both logical nesting and variable creation is a really nasty thing:
so this:
def qualifies_for_free_shipping(item_price, weight, shipping_factor, category):
if category is in FREE_SHIPPING_CATEGORIES:
return True
item_cost = item_price * TAX_RATE
shipping_cost = weight * shipping_factor + 2.00
total_price = item_cost + shipping_cost
if item_cost >= 80:
return True
if total_price >= 100 and category in ELECTRONICS_CATEGORIES:
return True
return False
becomes, in some lisp dialect I am making up but is like common lisp (defun qualifies-for-free-shipping (item-price weight shipping_factor category)
(if (in category FREE_SHIPPING_CATEGORIES)
t
(let* ((item-cost (* item-price TAX-RATE))
(shipping-cost (+ (* weight shipping-factor) 2))
(total-price (+ item-cost shipping-cost))
(if (>= item-cost 80)
t
(if (and (>= total-price 100) (in category ELECTRONICS-CATEGORIES))
t
nil)))))
I could have cleaned up the code and used a better conditional than nested if's or something, but this is my point. I can't just glance at the code and see what is going on, I have to parse it and keep track of where I am as I move around the s expressions. In the python version I can just jump in the middle and move around without keeping a mental bookmark, because I always know from indentation how I can get to where I am now.