Differences between revisions 1 and 2
Revision 1 as of 2005-01-04 15:11:06
Size: 3800
Editor: c-67-165-222-53
Comment: created page from python-list thread "Lambda as declarative idiom"
Revision 2 as of 2005-01-04 15:19:37
Size: 4057
Editor: c-67-165-222-53
Comment: added Roman Suzi's syntax and fixed links
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 117: Line 126:
 * [[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

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

   1 lambda a, b, c:f(a) + o(b) - o(c)
   2 lambda x: x * x
   3 lambda : x
   4 lambda *a, **k: x.bar(*a, **k)
   5 ((lambda x=x, a=a, k=k: x(*a, **k)) for x, a, k in funcs_and_args_list)

New Syntaxes

Args Before Expression

Nick Coghlan: def-to syntax #a 1

   1 (def (a, b, c) to f(a) + o(b) - o(c))
   2 (def (x) to x * x)
   3 (def () to x)
   4 (def (*a, **k) to x.bar(*a, **k))
   5 ((def (x=x, a=a, k=k) to x(*a, **k)) for x, a, k in funcs_and_args_list)

Nick Coghlan: def-arrow syntax #a 1

   1 (def (a, b, c) -> f(a) + o(b) - o(c))
   2 (def (x) -> x * x)
   3 (def () -> x)
   4 (def (*a, **k) -> x.bar(*a, **k))
   5 ((def (x=x, a=a, k=k) -> x(*a, **k)) for x, a, k in funcs_and_args_list)

Alex Martelli: def-as syntax #b 2

   1 (def (a, b, c) as f(a) + o(b) - o(c))
   2 (def (x) as x * x)
   3 (def () as x)
   4 (def (*a, **k) as x.bar(*a, **k))
   5 ((def (x=x, a=a, k=k) as x(*a, **k)) for x, a, k in funcs_and_args_list)

Dave Benjamin: fun syntax #g 7

   1 (fun(a, b, c): f(a) + o(b) - o(c))
   2 (fun(x): x * x)
   3 (fun(): x)
   4 (fun(*a, **k): x.bar(*a, **k))
   5 ((fun(x=x, a=a, k=k): x(*a, **k)) for x, a, k in funcs_and_args_list)

Roman Suzi: quote-colon syntax #i 9

   1 ` a, b, c:f(a) + o(b) - o(c)
   2 ` x: x * x
   3 ` : x
   4 ` *a, **k: x.bar(*a, **k)
   5 ((` x=x, a=a, k=k: x(*a, **k)) for x, a, k in funcs_and_args_list)

Expression Before Args

Nick Coghlan: for syntax #f 6

   1 (f(a) + o(b) - o(c) for (a, b, c))
   2 (x * x for (x))
   3 (x for ())
   4 (x.bar(*a, **k) for (*a, **k))
   5 ((x(*a, **k) for (x=x, a=a, k=k)) for x, a, k in funcs_and_args_list)

Robert Brewer: for (no-parens) syntax #c 3

   1 (f(a) + o(b) - o(c) for a, b, c)
   2 (x * x for x)
   3 (x for ())
   4 (x.bar(*a, **k) for *a, **k)
   5 ((x(*a, **k) for (x=x, a=a, k=k)) for x, a, k in funcs_and_args_list)

Nick Coghlan: def-from syntax #d 4

   1 (def f(a) + o(b) - o(c) from (a, b, c))
   2 (def x * x from (x))
   3 (def x from ())
   4 (def x.bar(*a, **k) from (*a, **k))
   5 ((def x(*a, **k) from (x=x, a=a, k=k)) for x, a, k in funcs_and_args_list)

Michael Spencer: from-args syntax #e 5

   1 (f(a) + o(b) - o(c) from args(a, b, c))
   2 (x * x from args(x))
   3 (x from args())
   4 (x.bar(*a, **k) from args(*a, **k))
   5 ((x(*a, **k) from args(x=x, a=a, k=k)) for x, a, k in funcs_and_args_list)

Michael Spencer: for-args syntax #e 5

   1 (f(a) + o(b) - o(c) for args(a, b, c))
   2 (x * x for args(x))
   3 (x for args())
   4 (x.bar(*a, **k) for args(*a, **k))
   5 ((x(*a, **k) for args()) for x, a, k in funcs_and_args_list)

Bengt Richter: colon-function-application syntax #h 8

   1 (:f(a) + o(b) - o(c))(a, b, c)
   2 (:x*x)(X)
   3 (:x)()
   4 (:x.bar(*a, **k))(*a, **k)
   5 ((:x(*a, **k))(x=x, a=a, k=k) for x, a, k in funcs_and_args_list)

References

AlternateLambdaSyntax (last edited 2008-11-15 14:00:18 by localhost)

Unable to edit the page? See the FrontPage for instructions.