Nick Coghlan wrote: > Guido van Rossum wrote: > >>>Recommend accepting just the basic PEP which only targets simple, >>>obvious cases. The discussed extensions are unattractive and should be >>>skipped. >> >> >>-1. The "unary colon" looks unPythonic to me. >> > > > Step 1 would be to require parentheses around the whole thing (ala > generator expressions) to make it easier to see where the deferred > expression ends. > > But all my use cases that I can think off the top of my head involve > 'sorted', where it wouldn't help at all because of the need for an > argument. > > So I'd rather see a serious discussion regarding giving lambdas a more > Pythonic syntax in general, rather than one that only applied to the > 'no-argument' case [1] > > Cheers, > Nick. > > [1] http://wiki.python.org/moin/AlternateLambdaSyntax > The 'expression-before-args' version using just the 'from' keyword is > still my favourite. >
Maybe anonymus function closures should be pushed forward right now not only syntactically? Personally I could live with lambda or several of the alternative syntaxes listed on the wiki page. But asking for a favourite syntax I would skip the "def" keyword from your def-arrow syntax proposal and use: ((a, b, c) -> f(a) + o(b) - o(c)) ((x) -> x * x) (() -> x) ((*a, **k) -> x.bar(*a, **k)) ( ((x=x, a=a, k=k) -> x(*a, **k)) for x, a, k in funcs_and_args_list) The arrow is a straightforward punctuation for function definitions. Reusing existing keywords for different semantics seems to me as a kind of inbreeding. For pushing anymus functions forward I propose to enable explizit partial evaluation as a programming technique: Example 1: >>> ((x,y) -> (x+1)*y**2) ((x,y) -> (x+1)*y**2) >>> ((x,y) -> (x+1)*y**2)(x=5) ((y) -> 6*y**2) Example 2: def f(x): return x**2 >>> ((x,y) -> f(x)+f(y))(x=2) ((y) -> 4 + f(y)) Example 3: >>> ((f,x,y) -> f(x)+f(y))(f=((x)-> x**2), y=3) ((x) -> ((x)-> x**2))(x)+9) The keyword style argument passing can be omitted in case of complete evaluation where pattern matching on the argument tuple is applied. Regards, Kay _______________________________________________ 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