Python's Lisp heritage

Jacek Generowicz jacek.generowicz at cern.ch
Sat Apr 27 05:13:48 EDT 2002


"Brian Quinlan" <brian at sweetapp.com> writes:

> Jacek wrote:
> > No, as Paul said, they are used for "function calls". Admittedly, in
> > mathematical expressions function call often coincide with
> > sub-expressions, but it does depend on the sub-expression in
> > question. Compare
> > 
> >    (+ 1 2 3 4 5 6 7 8 9 10)
> > 
> > with
> > 
> >    1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10
> > 
> > Gosh, what a lot of typing I have to do in Python, compared to lisp.
> 
> Actually, in your own example, the lisp example requires more typing.
> You disingenuously inserted unnecessary spaces in the Python example.
> Allow me to fix that:
> 
> Lisp:   (+ 1 2 3 4 5 6 7 8 9 10)
> Python: 1+2+3+4+5+6+7+8+9+10
> 
> You could also write it like:
> 
> >>> reduce(operator.add, (1,2,3,4,5,6,7,8,9,10))
> 55

(reduce #'+ '(1 2 3 4 5 6 7 8 9 10))

What, you mean that in python, if I want to refer to the funcion +, I
first have to import it from a separate module, and then call it
`add'? What a lot of typing ! :-) :-) :-)

(i.e. Let's not go off on completely pointless tangents.)

> Your example is not really interesting, except to show that lisp has a
> multi-argument add function and Python doesn't.

My example was indended to disabuse James of the notion that
parentheses are used in lisp "around sub expressions".

As I said in my reply to him, the example was partly in jest.

> Implementing one, as I demonstrated above, is a one liner e.g.
> 
> def add(*args): return reduce(operator.add, args)
> add(1,2,3,4,5,6,7,8,9,10)

Now go and implement it for all the other operators. Now go and
implement a CL environment in Python, and you can claim that every
feature of Common Lisp is available in Python (or whatever languague
you choose). :-)

But if you do that, then allow me to implement a Python in CL (I'm not
going to participatie in any ensuing discussions about which of the
two tasks is easier), thus proving that all computer languages are
absolutely identical, and I'm not talking about Turing equivalence :-)

Or maybe we should just stick to the point in question.



More information about the Python-list mailing list