A critic of Guido's blog on Python's lambda

Alex Martelli aleaxit at yahoo.com
Sun May 7 21:34:37 CEST 2006

Frank Buss <fb at frank-buss.de> wrote:

> Alex Martelli wrote:
> > Sorry, but I just don't see what lambda is buying you here.  Taking just
> > one simple example from the first page you quote, you have:
> > 
> > (defun blank ()
> >   "a blank picture"
> >   (lambda (a b c)
> >     (declare (ignore a b c))
> >     '()))
> You are right, for this example it is not useful. But I assume you need
> something like lambda for closures, e.g. from the page

Wrong and unfounded assumption.

> http://www.frank-buss.de/lisp/texture.html :
> (defun black-white (&key function limit)
>   (lambda (x y)
>     (if (> (funcall function x y) limit)
>         1.0
>       0.0)))
> This function returns a new function, which is parametrized with the
> supplied arguments and can be used later as building blocks for other
> functions and itself wraps input functions. I don't know Python good
> enough, maybe closures are possible with locale named function definitions,
> too.

They sure are, I gave many examples already all over the thread.  There
are *NO* semantic advantages for named vs unnamed functions in Python.

Not sure what the &key means here, but omitting that

def black_white(function, limit):
    def result(x,y):
        if function(x, y) > limit: return 1.0
        else: return 0.0
    return result


More information about the Python-list mailing list