Why is Python popular, while Lisp and Scheme aren't?
maney at pobox.com
maney at pobox.com
Wed Nov 13 17:55:18 EST 2002
Carl Banks <imbosol at vt.edu> wrote:
> Michael Hudson wrote:
>> *This* is asking to be written as a loop:
>
> Not for me. I wouldn't use a loop in this situation, unless the
> operations in the loop were dynamic. The loop interrupts the logical
I think I've already replied elsewhere to the alternation-into-loop
approach. I can disagree with both of you, somewhat. I like the idea of
organizing the pattern/action pairs in a fashion that draws attention to
their binding as a general notion. In practice, I don't see the necessary
mechanism to really do this in Python (can't def a function inside a list
literal, right? and Python's lambda falls 'way short for this). In the
specific situation, I don't feel the scale (up to half a dozen cases) is
such as to make the organizational advantages outweigh the obscuring of the
simple alternation logic that Carl refers to. If there were several tens of
cases, the organizational advantage would weigh more heavily.
> happening. I'll probably just factor the whole sequence into a
> function and use return when I got a match.
I was going to allude to a mildly annoying pile of state/context that would
need to be passed, but with the new nested scopes that I'm still not used to
expecting in Python...
> I guess some people have hissyfits if they have to use break or
> return; I don't.
Heck, I think gotos can be a superb way to implement a state machine;
returns and breaks bother me only when they're used in weird, ad-hoc ways.
The use of return you describe above is a well-known pattern in my book, so
it's fine.
> and-if-I-were-programming-in-C-I'd-just-use-goto-ly yr's
I've been writing in C (far from exclusively) since about 1980. Frankly,
I'm tired of working in assembler, even though it's quite the nicest
assembler I've ever used.
More information about the Python-list
mailing list