Python syntax in Lisp and Scheme
Alex Martelli
aleax at aleax.it
Thu Oct 9 12:13:54 EDT 2003
Doug Tolton wrote:
> David Mertz wrote:
>
>> There's something pathological in my posting untested code. One more
>> try:
>>
>> def categorize_jointly(preds, it):
>> results = [[] for _ in preds]
>> for x in it:
>> results[all(preds)(x)].append(x)
>> return results
>>
>> |Come on. Haskell has a nice type system. Python is an application of
>> |Greespun's Tenth Rule of programming.
>>
>> Btw. This is more nonsense. HOFs are not a special Lisp thing. Haskell
>> does them much better, for example... and so does Python.
>>
> What is your basis for that statement? I personally like the way Lisp
> does it much better, and I program in both Lisp and Python. With Python
> it's not immediately apparent if you are passing in a simple variable
> or a HOF. Whereas in lisp with #' it's immediately obvious that you are
> receiving or sending a HOF that will potentially alter how the call
> operates.
>
> IMO, that syntax is far clearner.
I think it's about a single namespace (Scheme, Python, Haskell, ...) vs
CLisp's dual namespaces. People get used pretty fast to having every
object (whether callable or not) "first-class" -- e.g. sendable as an
argument without any need for stropping or the like. To you, HOFs may
feel like special cases needing special syntax that toots horns and
rings bells; to people used to passing functions as arguments as a way
of living, that's as syntactically obtrusive as, say, O'CAML's mandate
that you use +. and not plain + when summing floats rather than ints
(it's been a couple years since I last studied O'CAML's, so for all I
know they may have changed that now, but, it IS in the book;-).
No doubt they could make a case that float arithmetic has potentially
weird and surprising characteristics and it's a great idea to make it
"immediately obvious" that's it in use -- and/or the case that this
allows stronger type inference and checking than SML's or Haskell's
use of plain + here allows. Rationalization is among the main uses
for the human brain, after all -- whatever feature one likes because
of habit, one can make SOME case or other for;-).
Alex
More information about the Python-list
mailing list