I sing the praises of lambda, my friend and savior!

Donn Cave donn at u.washington.edu
Wed Oct 13 17:21:56 EDT 2004


In article <mailman.4894.1097693029.5135.python-list at python.org>,
 "Clark C. Evans" <cce at clarkevans.com> wrote:

> On Wed, Oct 13, 2004 at 10:58:14AM -0700, Jeff Shannon wrote:
> | Antoon Pardon wrote:
> | >I find it better to let the coder decide what makes sense in his program
> | >and what not.
> | 
> | Which is the Perl philosophy.  Many people seem quite happy with Perl 
> | because of this TMTOWTDI attitude; personally, I prefer Python's clarity 
> | and simplicity.
> 
> On this list, that's damn near close to an ad hominem attack.
> 
> There are more than one way to do many of things in Python, and just
> about every "feature" that gets added is yet another way to do
> something that is already being done.   This doesn't stop features
> from being adopted, does it?  Every list comprehension has an
> equivalent version using a while-loop.  I could go on with examples,
> but your assertion is a leaky bucket, so why bother waste the space?
> Your arguments thus far have been "I don't use it, thus it probably
> isn't useful, and therefore, no one should be able to use it."  It's
> an uninformed position and frankly, not very helpful.

While I don't really agree that lambda ought to be jettisoned,
if that's the point in question, I do think that these are
legitimate questions.  The fact that list comprehensions for
example were adopted despite their redundance is indeed a
step backwards for the language as a whole, and if lambda were
being considered today for adoption it would need to be justified
in these terms.  "Let the coder decide" is not a good general
principle for language design, as suggested by counter-example above.

> I use lambda because it:
> 
>   - puts the definition of an expression right
>     where it is used;
> 
>   - doesn't require me to mint a name, or worry about
>     other possible calls to the same expression; and
> 
>   - is efficient use of vertical coding space.
> 
> All of these reasons provide clarity in maintaining code.  If you
> are working with a programming style that uses CPS, deferred
> execution, or similar mechanism with heavy callbacks or passing
> functions, you will understand the importance of the above features.

Fine, I have used it myself.  Since it's already in Python,
and in plenty of old code, there isn't much justification for
removing it.  But if it were time to clean Python up to conform
to the clarity and simplicity goals that one hears so much about,
lambda would be gone for sure.  Along with list comprehensions
and a boatload of gadgets.  If Python were a decent functional
programming language, lambda would work better and be a natural
if not very important part of the language, but that isn't the
case and it makes about as much sense as legs on a snake.  If
you really want a simple, clear language, that is.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list