Why is Python popular, while Lisp and Scheme aren't?

Alexander Schmolck a.schmolck at gmx.net
Sun Nov 24 18:57:54 EST 2002


Pascal Costanza <costanza at web.de> writes:

> 
> [...]
> 
> > python: CL: x = list[index] (elt arrayOrList index)
> 
> >  x = hash[key]                     (gethash key  hash) ;; *why* this arg-order?
> >  x = myType[indexOrKey]            ; no generalized item access
> >                                                                                    
> 
> [etc.]
> 
> Unified access is always a bit problematic. You should not access a list 
>   (in Common Lisp) by index because the list must always be traversed up 
> to the index on each access. (As far as I understand, what Python calls 

Of course you usually don't but then I can't see why this is an argument
against unified access (I don't want to abolish car and cdr and the writing of
nice recursive functions that manipulate lists with them). And anyway, as you
know, you can already access lists in CL by index if you want (and abuse it to
write really slow code, if you're incompetent; but sometimes its clearly the
right thing to do):

  (elt '(1 2 3 4) 2) => 3

Also often you just want to iterate over all the items in some container and I
can't really see how not having a good mechanism to this can be a good
thing. Why should I always need to tell LOOP that I want to iterate over a
vector and not a list?

  (loop for i in list) 

as opposed to 

  (loop for i across vector)

why not just:

  (loop for i in container)

If one is worried about the overhead for typechecking, one could always
optionally declare the type of the container, e.g.:

  (loop for i in (the list list))


> lists are in fact arrays, and arrays don't have that problem.)

Yes, I think python lists correspond best to resizable arrays in CL.

> (And you don't want to generally replace lists by arrays, because arrays 
> have their respective disadvantages as well.)

No of course you don't. But you do sometimes want to replace lists with arrays
or arrays with hashes or some more specialized container type after you've
already written some code, because the requirements and thus trade-offs
changed. In python it is then often easy to change the underlying container
type, in CL it isn't which presumably means that much code will not be
rewritten and that especially lists get overused. And then of course sometimes
you just want to write code that doesn't care about what exact container type
it receives to start with.

alex



More information about the Python-list mailing list