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.) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com