Python syntax in Lisp and Scheme

MetalOne jcb at iteris.com
Fri Oct 3 17:45:11 EDT 2003


kalath at lycos.com (Mark Brady) wrote in message news:<e840346c.0310030302.6be0c378 at posting.google.com>...
> Personally I find Scheme and Common Lisp easier to read but that's
> just me, I prefer S-exps ...

I am just barely familiar with Lisp and Scheme.  However, I always
find comments like the above interesting.  I have seen other people
make this claim also.
However, from an earlier post on comp.lang.python comparing a simple
loop.

Scheme
(define vector-fill!
  (lambda (v x)
    (let ((n (vector-length v)))
      (do ((i 0 (+ i 1)))
          ((= i n))
          (vector-set! v i x)))))

Python
def vector_fill(v, x):
    for i in range(len(v)):
        v[i] = x

To me the Python code is easier to read, and I can't possibly fathom
how somebody could think the Scheme code is easier to read.  It truly
boggles my mind.

The second thing that puzzles me is the usage of the LISP macro
system.  This system is touted as one of LISPs major strengths.  I
believe the "Do" above is a  macro.  Is that the best syntax that can
be achieved with a macro for "Do".  I would think there would already
be macros to write the Scheme code above in a format similar to the
Python code below, or some more readable syntax.  I have looked for
repositories of such macros and I can't find any.  This leads me to
think that in practice LISP macros are not used.  Couple this with the
fact that LISP programmers seem happier with S-exprs, and I can't see
why a LISP programmer would even want to write a macro.

I have tried on 3 occassions to become a LISP programmer, based upon
the constant touting of LISP as a more powerful language and that
ultimately S-exprs are a better syntax.  Each time, I have been
stopped because the S-expr syntax makes we want to vomit.

If a set of macros could be written to improve LISP syntax, then I
think that might be an amazing thing.  An interesting question to me
is why hasn't this already been done.




More information about the Python-list mailing list