Nick Coghlan wrote:
GvR has commented that he want to get rid of the lambda keyword for Python 3.0. Getting rid of lambda seems like a worthy goal, but I'd prefer to see it dropped in favour of a different syntax, rather than completely losing the ability to have anonymous functions.

Anyway, I'm looking for feedback on a def-based syntax that came up in a recent c.l.p discussion:
http://boredomandlaziness.skystorm.net/2004/12/anonymous-functions-in-python.html
...
The proposed syntax is:
accepts_func((def (a, b, c) to f(a) + g(b) - h(c)))
...

Cheers, Nick.

From the blog Comments:
Nick said...

A potentially easier to parse version moves the argument list to the end of the anonymous function and uses the existing keyword 'from'. That is:

(def f(a) + g(b) - h(c) from (a, b, c))
11:46 PM


Post a Comment



This alternative syntax seems more elegant to me because of the similarity with generator expressions. But the 'def' still seems awkward.


<Idle speculation>

Isn't the important point that the arguments have delayed evaluation? If so, the syntax could highlight this instead: i.e.,

    (f(a) + g(b) - h(c) from args(a, b, c))

and, in general:

    (expression from args(a, *args, **kw))

while we're at it, perhaps 'for' would be more appropriate:

    (expression for args(a, *args, **kw))



I also wonder if a callable, args, that stored its argument list for delayed evaluation would have other applications besides anonymous functions, but that is another topic

</Idle speculation>

Michael Spencer










-- http://mail.python.org/mailman/listinfo/python-list

Reply via email to