merits of Lisp vs Python

André Thieme address.good.until.2007.feb.05 at justmail.de
Fri Dec 15 21:27:44 EST 2006


Paul Rubin schrieb:
> André Thieme <address.good.until.2006.dec.22 at justmail.de> writes:
>> And I didn't count the indentation level and \n in Python code.
>> Why should I? They are editor commands.
> 
> No they're part of Python syntax.  A change in indent level is
> recognized by Python's lexical scanner as a token and you should count
> it.  You wouldn't count the indent and \n separately though.
> 
>>  > Anyway, token count doesn't mean much, you have to instead go by the
>>  > user's cognitive effort in dealing with the prefix notation etc.,
>>
>> How complicated ss it to say "cmp(a, b)" compared to  "a cmp b"?
> 
> It gets worse when the expressions are nested.

So instead of
cmp(foo(a, b, c), bar(x, y, z)) you would prefer
foo(a, b, c) cmp bar(x, y, z) ?

for x in 0 range len(s): ...

Maybe make single-digit functions postfix?

for x in 0 range (s)len: ...


>> Imagine Python would have an "anaphoric if", "aif". Then:
>>
>> aif timeConsumingCalculation():
>>    use(it)
> 
> Well, it's not really in the Pythonic style to add obscurity like
> that, but you could certainly write something like:
> 
>     def aif(func):
>        it = func()
>        if it: use(it)
> 
>     aif(timeConsumingCalculation)

This isn't doing the same. This hardencodes the call to use() inside
aif.

if timeConsumingCalculation():
   foo(it)
   bar(it)

But "if" is already taken for the standard if.
Instead we add a new keyword to Python, "aif".
Then we can say:

aif timeConsumingCalculation():
   foo(it)
   bar(it)

You can pass anonymous functions around etc, but it will become
ugly - no Pythoniast would ever do it in production code.
If there was an aif built into Python we would find it every
now and then.


André
-- 



More information about the Python-list mailing list