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

Carl Banks imbosol at vt.edu
Wed Nov 13 00:14:06 EST 2002


Martin Maney wrote:
> I'd love to "get" why some form of assignment on the fly is so evil that we
> have to invent hacks to work around its lack over and over again (recipie
> 1.9 in the Cookbook).  The lack interacts especially badly with a language
> where indentation is a mandantory part of the control structure.  :-(

Well, I highly disagree that changing assignment semantics is the
solution to this, for three reasons.  First, I have a general distaste
for anything that returns a value and has side effects.  Second, it
leads to all kinds of unreadability in the code by people abusing it.
Third, it is an incomplete solution.

The idiom you speak of is common enough.

do_A()
if test_based_on_A():
    take_action_A()
else:
    do_B()
    if test_based_on_B():
        take_action_B()
    else:
        do_C()
        if test_based_in_C():
            take_action_C()
        else:
            ...


The nesting goes on and on.  Changing assignment to an expression
can't solve this entirely, because sometimes do_A, do_B, do_C, etc.,
aren't tiny little assignments.  What you want is not a solution to
the real problem.

A new syntax would be the best solution, IMHO.  For example, the
suppose statement:

    suppose:
        do_A()
    if test_based_on_A():
        take_action_A()
    elsuppose:
        do_B()
    if test_based_on_B():
        take_action_B()

However, it is not likely to happen because it adds a new keyword, and
the idiom is not too common.  (Some will argue that it's hard to
follow, although I wouldn't say it's any harder than else: clauses on
fors and whiles.)

And, getting this back to the topic, you could do this if Python had
macros.  But I agree with Alex here; Python isn't the language for
that.  That's why we have Lisp.  Having the occasional useful syntax
not available (tryexcept anyone? conditional operator?) is a price
you pay sometimes.


-- 
CARL BANKS



More information about the Python-list mailing list