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

Antoon Pardon apardon at forel.vub.ac.be
Thu Oct 14 08:50:56 CEST 2004


Op 2004-10-13, Jeff Shannon schreef <jeff at ccvcorp.com>:
> Antoon Pardon wrote:
>
>>Op 2004-10-12, Jeff Shannon schreef <jeff at ccvcorp.com>:
>>  
>>
>>>Functions are at a different level of granularity than numbers and 
>>>lists.  Anonymity makes sense for numbers and lists; it makes less sense 
>>>for collections of numbers and lists; and it makes still less sense for 
>>>organized collections of numbers, lists, and operations thereon, which 
>>>are structured in a meaningful way to express some (part of an) 
>>>algorithm.
>>>    
>>>
>>
>>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.

Well if that is the Perl attitude, please inform me who is to decide
what makes sense and what not to put in a program according to the
Python philosophy.


>>>Similarly, I don't expect each line of code to have an 
>>>individual name, but once I collect lines of code into a file, I 
>>>certainly *do* expect to name that file, even if the file is only one or 
>>>two lines long.
>>>    
>>>
>>
>>So? If you then want to develop the code, do you put the new code in a
>>new file and then use a program to include it, or do you put unnamed
>>text in the already existing file?
>>  
>>
>
> Actually, I effectively do both of those, depending on circumstances.  
> (Opening a new editor, typing in it, and then pasting that text into the 
> middle of an existing file.)  However, in this (admittedly weak, 
> especially when pushed this far) analogy, a lambda is equivalent to 
> putting the text in a new file, and insisting that that file not be 
> given a name and be kept separate from the parent file, but be 
> programmatically included nonetheless.  Would you *want* to do that, 
> even if your operating system allowed it?

But a lambda has a name, if it hasn't it would be useless, just a
temporary one. Lamda's are typically used as an argument to a function
or method. Within that function they have a name. In that respect they
are no different from a list literal. And list literals are just
as much part of the code as lambda's. So are you argueing against
list literals as parameters or in expressions too? Because this
analogy of yours doesn't make a distinction between lambda's and
lists.

-- 
Antoon Pardon



More information about the Python-list mailing list