Re: better lambda support in the future?

2004-12-21 Thread Antoon Pardon
Op 2004-12-17, Terry Reedy schreef [EMAIL PROTECTED]: Jason Zheng [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Steven Bethard wrote: Jason Zheng wrote: I'm wondering why python still has limited lambda support. What's stopping the developers of python to support more

Re: better lambda support in the future?

2004-12-18 Thread Terry Reedy
Bengt Richter [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Looks like your standard pattern could be updated: dispatch = {} def dispvia(name): ... def _(f, name=name): ... dispatch[name] = f ... return f ... return _ ... @dispvia('a') ... def

Re: better lambda support in the future?

2004-12-18 Thread Nick Coghlan
Terry Reedy wrote: To avoid the redundancy of 'a' and '_a', etc, how about (untested): def dispvia(f): dispatch[f.__name__.split('_')[1]] = f return f A similar idea: Py class DispatchTable(dict): ... def __init__(self, prefix=): ... self._prefix = prefix ... self._ignored =

Re: better lambda support in the future?

2004-12-18 Thread Dima Dorfman
On 2004-12-18, Terry Reedy [EMAIL PROTECTED] wrote: Dima Dorfman [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Both languages compile all three functions (f and the two versions of g) once and choose which g to return at run-time. *If* OCaml or any other 'other' language

Re: better lambda support in the future?

2004-12-18 Thread Robin Becker
Terry Reedy wrote: Jp Calderone [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy [EMAIL PROTECTED] wrote: . For one-off uses not eligible for lambda treatment, where you really do not care about the name, use the same name, such as

Re: better lambda support in the future?

2004-12-18 Thread Doug Holton
Jason Zheng wrote: I'm wondering why python still has limited lambda support. What's stopping the developers of python to support more lisp-like lambda function? See boo and its support for closures: http://boo.codehaus.org/ http://boo.codehaus.org/Closures It works with def or do, or

Re: better lambda support in the future?

2004-12-18 Thread Nick Coghlan
Bengt Richter wrote: It is a little sneaky though, so it might not be prudent to promote without a little more experimentation? I just like to explore ;-) I don't think even the py-dev discussions of this settled on whether such tricks were very cool or downright evil. They're probably less evil

better lambda support in the future?

2004-12-17 Thread Jason Zheng
I'm wondering why python still has limited lambda support. What's stopping the developers of python to support more lisp-like lambda function? -- http://mail.python.org/mailman/listinfo/python-list

Re: better lambda support in the future?

2004-12-17 Thread elbertlev
Lambda functions will become obsolette in the nearest future. This is the PLAN. -- http://mail.python.org/mailman/listinfo/python-list

Re: better lambda support in the future?

2004-12-17 Thread Fredrik Lundh
Steven Bethard wrote: Even if you could settle the syntax issue, once you've decided that you really do need a true block in an anonymous function, you're not really saving much space by not declaring it: def f(*args): # body line 1 # body line 2 # ... # body line N

Re: better lambda support in the future?

2004-12-17 Thread Michael DeHaan
True enough, but suppose you want a hash of anonymous functions as opposed to just a lexical? This is where lambas are nice to have. Totally agreed about a small use here and there, but they do have some use in dispatch tables, as they are a lot easier to read sometimes than very long case

Re: better lambda support in the future?

2004-12-17 Thread Fredrik Lundh
Steven Bethard wrote: You're welcome to name the function whatever you want -- notice in my example that the function is used in the statement: x = func or f If you'd prefer the statement to read: x = func or x that's also fine. Depends on what exactly 'x' is, and whether or not it

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Michael DeHaan wrote: True enough, but suppose you want a hash of anonymous functions as opposed to just a lexical? I've seen at least one reasonable example of this kind of thing: http://mail.python.org/pipermail/python-list/2004-October/245432.html Though I haven't yet seen an example that

Re: better lambda support in the future?

2004-12-17 Thread Fredrik Lundh
Michael DeHaan wrote: True enough, but suppose you want a hash of anonymous functions as opposed to just a lexical? This is where lambas are nice to have. Totally agreed about a small use here and there, but they do have some use in dispatch tables, as they are a lot easier to read

Re: better lambda support in the future?

2004-12-17 Thread Jason Zheng
Steven Bethard wrote: Jason Zheng wrote: I'm wondering why python still has limited lambda support. What's stopping the developers of python to support more lisp-like lambda function? This comes up every few weeks on the list. If you haven't already, check the archives in Google for

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Jason Zheng wrote: The true beauty of lambda function is not the convenience of creating functions without naming them. Lambda constructs truly enables higher-order function. For example, I can create a function A that returns a function B that does something interesting according to the

Re: better lambda support in the future?

2004-12-17 Thread Fredrik Lundh
Steven Bethard wrote: I've seen at least one reasonable example of this kind of thing: http://mail.python.org/pipermail/python-list/2004-October/245432.html the code he's referring to doesn't seem to use that construct anymore, so it's not obvious what dejavu.icontains etc really is, but

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Fredrik Lundh wrote: Steven Bethard wrote: I've seen at least one reasonable example of this kind of thing: http://mail.python.org/pipermail/python-list/2004-October/245432.html the code he's referring to doesn't seem to use that construct anymore, so it's not obvious what dejavu.icontains etc

Re: better lambda support in the future?

2004-12-17 Thread Terry Reedy
Jason Zheng [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Steven Bethard wrote: Jason Zheng wrote: I'm wondering why python still has limited lambda support. What's stopping the developers of python to support more lisp-like lambda function? They already have: given the

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Jeff Shannon wrote: It occurs to me that, in a statically compiled language, function definitions all happen before the program starts, and thus that definition can't be affected by other variables (i.e. an outer function's parameters). I think you might be confusing static compilation in a

Re: better lambda support in the future?

2004-12-17 Thread Jp Calderone
On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy [EMAIL PROTECTED] wrote: Jason Zheng [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Steven Bethard wrote: Jason Zheng wrote: I'm wondering why python still has limited lambda support. What's stopping the developers of python

Re: better lambda support in the future?

2004-12-17 Thread Harlin Seritt
Jp Calderone wrote: On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy [EMAIL PROTECTED] wrote: Jason Zheng [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Steven Bethard wrote: Jason Zheng wrote: I'm wondering why python still has limited lambda support. What's stopping the

Re: better lambda support in the future?

2004-12-17 Thread Jeff Shannon
Steven Bethard wrote: Jeff Shannon wrote: It occurs to me that, in a statically compiled language, function definitions all happen before the program starts, and thus that definition can't be affected by other variables (i.e. an outer function's parameters). I think you might be confusing

Re: better lambda support in the future?

2004-12-17 Thread Mike Meyer
Jeff Shannon [EMAIL PROTECTED] writes: Steven Bethard wrote: Hm, possibly. I must confess that my direct knowledge is limited to a fairly narrow set of languages, and that C and C++ are the only statically-compiled languages I've used. Still, I'm not sure that it's just a matter of

Re: better lambda support in the future?

2004-12-17 Thread Dima Dorfman
On 2004-12-18, Jeff Shannon [EMAIL PROTECTED] wrote: Would OCaml (or some other static language) have something that's equivalent to this? def f(x): if x 0: def g(y): return y * -1 else: def g(y): return y return g foo = f(1)

Re: better lambda support in the future?

2004-12-17 Thread Bengt Richter
On Fri, 17 Dec 2004 22:56:08 +0100, Fredrik Lundh [EMAIL PROTECTED] wrote: Michael DeHaan wrote: True enough, but suppose you want a hash of anonymous functions as opposed to just a lexical? This is where lambas are nice to have. Totally agreed about a small use here and there, but they do

Re: better lambda support in the future?

2004-12-17 Thread Nick Coghlan
Jp Calderone wrote: Regarding #1: there must be a great variance between people in the difficulty of some aspects of programming. I am always amazed to hear from people who have no difficulty picking names for all of their functions. This is a task that often stumps me for long minutes. My