Why is Python popular, while Lisp and Scheme aren't?
Andreas Leitgeb
Andreas.Leitgeb at siemens.at
Tue Nov 12 10:24:14 EST 2002
Pascal Costanza <costanza at web.de> wrote:
>> I quote one function from AisleRiot (game Kansas):
>> " (define (button-pressed slot-id card-list)
>> " (and (not (= (length card-list) 0))
>> " (is-visible? (car card-list))
>> " (or (= slot-id 1)
>> " (> slot-id 5))))
> If you are used to this kind of syntax, it's very simple. I don't know
> enough Python (yet) in order to translate this, but in Java it would
> look as follows.
> 1 boolean buttonPressed (int slotId, Vector cardList) {
> 2 return !(cardList.size() == 0) &&
> 3 cardList.get(0).isVisible() &&
> 4 ((slotId == 1) || (slotId > 5));
> 5 }
I'd have rewritten it differently (to show the point I was
trying to make by calling the scheme-snippet ugly):
2 if (cardList.size() == 0) return false;
3 else if (!cardList.get(0).isVisible()) return false;
4 else return ((slotId == 1) || (slotId > 5));
Now this doesn't make a big difference here, but it makes
a lot of a difference, once, things get longer and deeper nested.
> My basic message here is that you might like Common Lisp more than
> Scheme. *nudge, nudge*
I'm not sure if I can really see the difference yet (beyond some
differently named predefined symbols/keywords).
Since almost every modern language (worth mentioning) has the concept
of short cutting boolean evaluation, one could write Lisp/Scheme
style everywhere; Nevertheless I'm glad it's not so common anywhere
else.
More information about the Python-list
mailing list