Lambda as declarative idiom (was RE: what is lambda used for in real code?)

Roman Suzi rnd at onego.ru
Tue Jan 4 12:46:47 EST 2005


On Tue, 4 Jan 2005, Steven Bethard wrote:

>Roman Suzi wrote:
>> On Mon, 3 Jan 2005, Steven Bethard wrote:
>>
>>
>>>Roman Suzi wrote:
>>>
>>>>I wish lambdas will not be deprecated in Python but the key to that is
>>>>dropping the keyword (lambda). If anybody could think of a better syntax for
>>>>lambdas _with_ arguments, we could develop PEP 312 further.
>>>
>>>Some suggestions from recent lambda threads (I only considered the ones
>>>that keep lambda as an expression):
>>
>> Wow! Is there any wiki-page these could be put on?
>
>It's now on:
>
>http://www.python.org/moin/AlternateLambdaSyntax
>
>and I added Bengt Richter's and your recent suggestions.

Hmmm... what if we kill two rabbits in one blow: lambda will be even
more implicit, if we just mark parameters by a back-quote while
using PEP 312 convention:

(:f(`a) + o(`b) - o(`c))
(:`x * `x)
(:x)
(:x.bar(*`a, **`k))

Not sure about default args:

((fun(x=x, a=a, k=k): x(*a, **k)) for x, a, k in funcs_and_args_list)

Maybe this needs to be done with closures.
Otherwise I think Python interpreter is quite capable to determine
which parameters the function has... Only their order become a problem.
Probably, ","-s could be used there:

(`a,`b,`c : f(`a) + o(`b) - o(`c))

The whole expressions could be quoted:

`(x, y, z)

meaning a parameter with such structure.



>Steve
>

Sincerely yours, Roman Suzi
-- 
rnd at onego.ru =\= My AI powered by GNU/Linux RedHat 7.3



More information about the Python-list mailing list