Size: 3800
Comment: created page from python-list thread "Lambda as declarative idiom"
|
Size: 4707
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 17: | Line 17: |
Nick Coghlan: def-to syntax [1] | Nick Coghlan: def-to syntax [[#a 1]] |
Line 26: | Line 26: |
Nick Coghlan: def-arrow syntax [1] | Nick Coghlan: def-arrow syntax [[#a 1]] |
Line 35: | Line 35: |
Alex Martelli: def-as syntax [2] | Alex Martelli: def-as syntax [[#b 2]] |
Line 44: | Line 44: |
Dave Benjamin: fun syntax [7] | Dave Benjamin: fun syntax [[#g 7]] |
Line 53: | Line 53: |
Roman Suzi: quote-colon syntax [[#i 9]] {{{#!python ` 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) }}} |
|
Line 55: | Line 64: |
Nick Coghlan: for syntax [6] | Nick Coghlan: for syntax [[#f 6]] |
Line 64: | Line 73: |
Robert Brewer: for (no-parens) syntax [3] | Robert Brewer: for (no-parens) syntax [[#c 3]] |
Line 73: | Line 82: |
Nick Coghlan: def-from syntax [4] | Nick Coghlan: def-from syntax [[#d 4]] |
Line 82: | Line 91: |
Michael Spencer: from-args syntax [5] | Michael Spencer: from-args syntax [[#e 5]] |
Line 91: | Line 100: |
Michael Spencer: for-args syntax [5] | Michael Spencer: for-args syntax [[#e 5]] |
Line 100: | Line 109: |
Bengt Richter: colon-function-application syntax [9] | Bengt Richter: colon-function-application syntax [[#h 8]] |
Line 108: | Line 117: |
=== Real Closures === Real closures subsume the functionality of lambda plus allow for multi-line statements. ---- Curly braces for single-line and anonymous def for multi-line (from [[#h 10]], boo [[#h 11]], and this is also very similar to how Ruby does it): {{{#!python #single-line (similar to ruby syntax) {a,b,c | return f(a) + o(b) - o(c)} {x | return x*x} {return x} {*a, **k | return x.bar(*a, **k)} #multi-line x = def (a,b,c): return f(a) + o(b) - o(c) }}} |
|
Line 117: | Line 146: |
* [[Anchor(h)]] [8] http://mail.python.org/pipermail/python-list/2005-January/258238.html * [[Anchor(i)]] [9] http://mail.python.org/pipermail/python-list/2005-January/258578.html |
* [[Anchor(h)]] [8] http://mail.python.org/pipermail/python-list/2005-January/258578.html * [[Anchor(i)]] [9] http://mail.python.org/pipermail/python-list/2005-January/258581.html * [[Anchor(i)]] [10] http://mail.python.org/pipermail/python-list/2005-January/258113.html * [[Anchor(i)]] [11] http://boo.codehaus.org/Closures |
As it stands, Guido van Rossum has suggested that lambda forms will disappear in ["Python3.0"]. This started a number of threads on comp.lang.python suggesting alternate syntaxes for lambda in the hopes that one of them might be more amenable to GvR's tastes. This pages summarizes these suggestions:
Current Syntax
New Syntaxes
Args Before Expression
Nick Coghlan: def-to syntax #a 1
Nick Coghlan: def-arrow syntax #a 1
Alex Martelli: def-as syntax #b 2
Dave Benjamin: fun syntax #g 7
Roman Suzi: quote-colon syntax #i 9
Expression Before Args
Nick Coghlan: for syntax #f 6
Robert Brewer: for (no-parens) syntax #c 3
Nick Coghlan: def-from syntax #d 4
Michael Spencer: from-args syntax #e 5
Michael Spencer: for-args syntax #e 5
Bengt Richter: colon-function-application syntax #h 8
Real Closures
Real closures subsume the functionality of lambda plus allow for multi-line statements.
Curly braces for single-line and anonymous def for multi-line (from #h 10, boo #h 11, and this is also very similar to how Ruby does it):
References
Anchor(a) [1] http://mail.python.org/pipermail/python-list/2004-December/256859.html
Anchor(b) [2] http://mail.python.org/pipermail/python-list/2004-December/256881.html
Anchor(c) [3] http://mail.python.org/pipermail/python-list/2004-December/257023.html
Anchor(d) [4] http://boredomandlaziness.skystorm.net/2004/12/anonymous-functions-in-python.html
Anchor(e) [5] http://mail.python.org/pipermail/python-list/2004-December/257893.html
Anchor(f) [6] http://mail.python.org/pipermail/python-list/2004-December/257977.html
Anchor(g) [7] http://mail.python.org/pipermail/python-list/2005-January/258441.html
Anchor(h) [8] http://mail.python.org/pipermail/python-list/2005-January/258578.html
Anchor(i) [9] http://mail.python.org/pipermail/python-list/2005-January/258581.html
Anchor(i) [10]
http://mail.python.org/pipermail/python-list/2005-January/258113.html
Anchor(i) [11]