merits of Lisp vs Python

Pascal Costanza pc at p-cos.net
Tue Dec 12 06:56:11 EST 2006


Paul Rubin wrote:
> Pascal Costanza <pc at p-cos.net> writes:
>> May you have tried the wrong Lisp dialects so far:
>>
>> (loop for i from 2 to 10 by 2
>>        do (print i))
> 
> The loop language is so complicated and confusing that I never
> bothered trying to learn it.

You can start with loop by using only the simple and straightforward 
constructs, and slowly move towards the more complicated cases when 
necessary. The nice thing about loop is that with some practice, you can 
write code that more or less reads like English.

 > I always used simpler primitives to
 > write loops and it was always enough.

No language construct is so simple that it cannot be replaced with a 
combination of simpler primitives.

>> This is Common Lisp. (Many Lisp and Scheme tutorials teach you that
>> you should implement this using recursion, but you really don't have
>> to. ;)
> 
> You can't really use that much recursion in Lisp because of the lack
> of guaranteed TCO.  I think that makes it reasonable to say that
> Scheme is a functional language but Lisp is not.  ("Functional" = it's
> reasonable to code in a style where the only way to connect variables
> to values is lambda binding (maybe through syntax sugar), so all loops
> are implemented with recursion).

All Common Lisp implementations that I am aware of provide ways to 
enable TCO, so it's definitely possible to program in a functional style 
if you want to. It's just that the ANSI Common Lisp specification 
doesn't guarantee this, but this doesn't matter much. The only downside 
is that there is no common interface to enable TCO - that would indeed 
be an improvement. The upside is that you can switch TCO off if you want 
to, which for example may improve debugging.

It's correct that Scheme has a stronger tendency towards functional 
programming than Lisp has.


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/



More information about the Python-list mailing list