Python syntax in Lisp and Scheme

Donn Cave donn at u.washington.edu
Tue Oct 14 13:08:58 EDT 2003


In article <m2zng4w05m.fsf at mycroft.actrix.gen.nz>,
 Paul Foley <see at below.invalid> wrote:
> On Tue, 14 Oct 2003 01:26:54 -0400, David Mertz wrote:
...
>> In point of fact, Python could completely eliminate the operator
>> 'lambda', and remain exactly as useful for HOFs. Some Pythonistas seem
>> to want this, and it might well happen in Python3000.  It makes no
>> difference... the alpha and omega of HOFs is that functions are first
>> class objects that can be passed and returned.  Whether they happen to
>> have names is utterly irrelevant, anonymity is nothing special.
> 
> True enough.  Naming things is a pain though.  Imagine if you couldn't
> use numbers without naming them: e.g., if instead of 2 + 3 you had to
> do something like
> 
>   two = 2
>   three = 3
>   two + three
> 
> Bleargh!  It "makes no difference" in much the same way that using
> assembler instead of Python "makes no difference" -- you can do the
> same thing either one, but one way is enormously more painful.
> 
> [Mind you, Python's lambda is next to useless anyway]

Sure, Python is a procedural programming language with things
like "if" statements that don't play very well in the context
of a lambda body, and with a notion of identifiers, variables
and scope that doesn't favor some of the conveniences that
lambda writers enjoy in functional programming languages.  So
lambda is doomed to suffer from some limitations, and this seems
to bug some people no end.

It isn't clear that there's a real problem here, though, as
opposed to an occasion for contributing to the hot air supply
on USENET.  (Heavens, what possessed me to read any of this
thread!?)  Even if you suppose that Python programmers have
the same need for lambdas as one would in an FPL, what little
value they have is clearly in just the kind of applications
that actually work in Python anyway.  The last time this came
up in another newsgroup, I rewrote a sort of well known
snippet of Haskell (a state monad) with named functions in
place of the lamdbdas the way you always see it, and proposed
that it was easier to read that way, and if anyone came forward
to contradict me I don't recall it.  I think there is some
perverse thriftiness in most of us that makes us want to economise
on a carriage return here a name there, until our code becomes
so distilled that it's too perfect - too hard to understand.
Python is not about this kind of perfection, in my opinion.

   Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list