On Fri, 08 Dec 2006 22:02:59 +0200, Alex Mizrahi wrote:

> you have an expression 3 + 4 which yields 7.
> you have an expression 4 * 1 which yields 4.
> if you paste 3 + 4 in place of 1, you'll have 4 * 3 + 4 = 16. as we know, * 
> is commutative, but 3 + 4 * 4 = 19.
> so result depends on implicit operator precendence rules.
> 
> in lisp, if you paste (+ 3 4) in (* 4 1), you'll have (* 4 (+ 3 4)), and it 
> does not depend on order of operands, (* (+ 3 4) 4) yields same results. you 
> do not have to remember precendence rules 

Speaking as somebody who programmed in FORTH for a while, that doesn't
impress me much. Prefix/postfix notation is, generally speaking, more of a
pain in the rear end than it is worth, even if it saves you a tiny bit of
thought when pasting code.

Except, of course, it doesn't really save you any thought. You can't just
expect to paste an expression randomly into another expression and have it
do the right thing. Oh, it will compile all right. But it won't do the
right thing! Since you -- not the compiler -- have to understand the
semantics of what you are pasting where, and paste the right expression
into the right place, the effort saved by not using infix notation is less
than the effort needed to mentally translate between prefix and infix.

If you are one of those people who actually think in prefix notation, then
I raise my hat to you while backing away slowly.

(And actually, I'll give you one point: I've been hitting my head against
a brick wall over a particular problem, and I think your email just gave
me a clue how to solve it. Sometimes prefix/postfix notation is the right
tool for the job. See, I can learn from Lisp.)



-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to