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

Pascal Costanza costanza at web.de
Sun Nov 24 20:13:11 EST 2002


Alexander Schmolck wrote:
> 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).

My guess is that the CL designers wanted us to make conscious decisions 
in this regard, so they opted for "non-unified" access by default. But I 
admit that I am not sure about what's the best option here and I see 
that you have some points.

> 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)
> 

Well, you can always do the following.

(map nil (lambda (i) (...)) container)

And if you want to have a nicer syntax:

(defmacro dosequence ((element container) &body body)
   `(map nil (lambda (,element) , at body) ,container))

Now you can do both.

(dosequence (i '(1 2 3))
   (print i))

(dosequence (i #(1 2 3))
   (print i))


Pascal

-- 
Given any rule, however ‘fundamental’ or ‘necessary’ for science, there 
are always circumstances when it is advisable not only to ignore the 
rule, but to adopt its opposite. - Paul Feyerabend




More information about the Python-list mailing list