[Python-Dev] Recommend accepting PEP 312 -- Simple Implicit Lambda

Ron Adam rrr at ronadam.com
Sun Jun 19 18:21:40 CEST 2005


Nick Coghlan wrote:
> Donovan Baarda wrote:
> 
>>As I see it, a lambda is an anonymous function. An anonymous function is 
>>a function without a name.
> 
> 
> And here we see why I'm such a fan of the term 'deferred expression' 
> instead of 'anonymous function'.
 >
> Python's lambda expressions *are* the former, but they are 
> emphatically *not* the latter.

Lambda's have inputs and outputs like a function, so they can be used in 
place of functions.

A simple deferred expression wouldn't be the same thing since it would 
use local names directly, but not at the time the expression is created, 
and couldn't (easily) be used in place of a function call.

addxy = defer x+y          # do this later
for x in range(10):
     for y in range(10):
         print addxy        # prints sums of x,y

This is basically a limited single expression macro. (Which I believe 
isn't wanted.)  A better example might be as used in a dictionary in 
place of a case statement.  ie..  case['add'] = defer x+y, etc...

Regards, Ron

(Reply to this in python-list if it would be better discussed there.)



More information about the Python-Dev mailing list