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

Patrick May pjm at spe.com
Sun May 7 15:49:58 EDT 2006


aleaxit at yahoo.com (Alex Martelli) writes:
>> >> In my opinion (and that of several others), the best way for
>> >> Python to grow in this regard would be to _lose_ lambda
>> >> altogether, since named functions are preferable
>> >
>> >      Why?  I find the ability to create unnamed functions on the
>> > fly to be a significant benefit when coding in Common Lisp.
>> 
>> 1. They don't add anything new to the language semantically
>>    i.e. you can always used a named function to accomplish the same
>>    task as an unnamed one.

     Sure, but it won't necessarily be as expressive or as convenient.

>> 2. Giving a function a name acts as documentation (and a named
>>    function is more likely to be explicitly documented than an
>>    unnamed one). This argument is pragmatic rather than
>>    theoretical.

     Using lambda in an expression communicates the fact that it will
be used only in the scope of that expression.  Another benefit is that
declaration at the point of use means that all necessary context is
available without having to look elsewhere.  Those are two pragmatic
benefits.

>> 3. It adds another construction to the language.

     That's a very minimal cost relative to the benefits.

     You haven't made your case for named functions being preferable.

Regards,

Patrick

------------------------------------------------------------------------
S P Engineering, Inc.    | The experts in large scale distributed OO
                         | systems design and implementation.
          pjm at spe.com    | (C++, Java, Common Lisp, Jini, CORBA, UML)



More information about the Python-list mailing list