Python syntax in Lisp and Scheme

Doug Tolton doug at nospam.com
Thu Oct 9 15:18:10 EDT 2003


Alex Martelli wrote:

> 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;-).
Yeah I'm not a big fan of +. and /. etc.  Every operation on floating 
point values has to be explicitly specified.  You can't even do a 2 +. 
3.0.  Instead you have do do (float_of_int 2) +. 3.0
I'm not a huge fan of their syntax either.  I don't think they've 
removed it, because it's in the first chapter of the tutorial on their site.

I also uses HOF's daily, and I don't generally run into problems 
specifying that a variable is in fact a function.  I like the sharp 
quote thouge because it makes it clear that something a little out of 
the ordinary is occurring.  Honestly though either way is fine with me. 
  I can see the arguments both ways.

btw CLisp is an implementation of Common Lisp.  If you want to shorten 
it, it's usually less ambiquous if you use CL.

I'm not going to comment on the dual versus single namespaces, because 
that isn't an area I'm very familiar with how Lisp operates.


-- 
Doug Tolton
(format t "~a@~a~a.~a" "dtolton" "ya" "hoo" "com")





More information about the Python-list mailing list