Let's Talk About Lambda Functions!
bokr at oz.net
Thu Aug 1 20:25:01 CEST 2002
On Sun, 28 Jul 2002 07:58:37 GMT, "Fredrik Lundh" <fredrik at pythonware.com> wrote:
>Bryan Olson wrote:
>> The mistake was limiting lambda to expressions.
>Guido can channel himself (or Tim will do it), but from what
>I can tell, he's always said that the "mistake" was adding
>something to the language that almost, but not completely,
>works like lambdas do in other languages.
>(lambda, map, filter, etc was contributed code)
>the really big usage problem (whether you knew lambdas
>from other languages or not) used to be that they were a
>real pain to use under the LGB scoping rule. with the intro-
>duction of nested scopes, that problem no longer exists.
>to fix the other "mistake", some needs to come up with a
>really great syntax (and get michael hudson to implement
>it for them ;-). ideas are welcome.
Just leave out the name after the def to make it anonymous,
and use parens to make the scope of the def expression obvious, e.g.,
x = y + (
if z: return 'True z'
else: return 'False z'
)('arg for anonymous function') + ' & additional expression terms.'
More information about the Python-list