Re: A replacement for lambda

2005-07-31 Thread Bengt Richter
On Sun, 31 Jul 2005 00:30:36 -0400, Mike Meyer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Bengt Richter) writes: On Fri, 29 Jul 2005 18:07:31 -0400, Mike Meyer [EMAIL PROTECTED] wrote: I know, lambda bashing (and defending) in the group is one of the most popular ways to avoid writing code.

Re: A replacement for lambda

2005-07-30 Thread Paul Rubin
James Richards [EMAIL PROTECTED] writes: Personally, I can't recall any decent programmer I know who objects to actually writing out a variable name. In fact, I don't know a single real programmer (this is one who writes programs he intends to look at again in, say, 3 weeks) who doesn't

Re: A replacement for lambda

2005-07-30 Thread Kay Schluehr
Tim Roberts schrieb: Scott David Daniels [EMAIL PROTECTED] wrote: What kind of shenanigans must a parser go through to translate: x**2 with(x)x**3 with(x) this is the comparison of two functions, but it looks like a left- shift on a function until the second with is encountered.

Re: A replacement for lambda

2005-07-30 Thread Paolino
why (x**2 with(x))(x**3 with(x)) is not taken in consideration? If 'with' must be there (and substitue 'lambda:') then at least the syntax is clear.IMO Ruby syntax is also clear. ___ Yahoo! Mail: gratis 1GB per i messaggi e

Re: A replacement for lambda

2005-07-30 Thread D H
Mike Meyer wrote: Rewriting a canonical abuse of lambda in this idiom gives: myfunc = def @(*args): return sum(x + 1 for x in args) Nice proposal. Technically you don't need the @ there, it is superfluous. But then again so is the colon, so whatever floats your boat. class

Re: A replacement for lambda

2005-07-30 Thread Paul Rubin
D H [EMAIL PROTECTED] writes: where fdel = def (self): ... As you can see, it doesn't save much over the traditional way since you have to name the anonymous lambdas anyway. It saves polluting the surrounding namespace with superfluous variables

Re: A replacement for lambda

2005-07-30 Thread Paddy
Christopher Subich [EMAIL PROTECTED] writes: Basically, I'd rewrite the Python grammar such that: lambda_form ::= expression with parameter_list I do prefer my parameter list to come before the expression. It would remain consistant with simple function definitions. - Cheers, Paddy. --

Re: A replacement for lambda

2005-07-30 Thread Stefan Rank
on 30.07.2005 10:20 Paolino said the following: why (x**2 with(x))(x**3 with(x)) is not taken in consideration? If 'with' must be there (and substitue 'lambda:') then at least the syntax is clear.IMO Ruby syntax is also clear. I am sorry if this has already been proposed (I am sure it

Re: A replacement for lambda

2005-07-30 Thread Paul Rubin
Stefan Rank [EMAIL PROTECTED] writes: I am sorry if this has already been proposed (I am sure it has). Why not substitue python-lambdas with degenerated generator expressions:: (lambda x: func(x)) == (func(x) for x) I don't think I've seen that one before, and FWIW it's kind of cute. But

Re: A replacement for lambda

2005-07-30 Thread Kay Schluehr
Mike Meyer schrieb: I know, lambda bashing (and defending) in the group is one of the most popular ways to avoid writing code. However, while staring at some Oz code, I noticed a feature that would seem to make both groups happy - if we can figure out how to avoid the ugly syntax. This

Re: A replacement for lambda

2005-07-30 Thread Paul Rubin
Kay Schluehr [EMAIL PROTECTED] writes: Examples: f = ( || x=0 then f(x) || True then f(-x) from (x,) ) g = ( || x 0 then self._a -x || self._a - 0 from (x,)) Is this an actual language? It looks sort of like CSP. Python with native parallelism, m. --

Re: A replacement for lambda

2005-07-30 Thread Kay Schluehr
Paul Rubin wrote: Kay Schluehr [EMAIL PROTECTED] writes: Examples: f = ( || x=0 then f(x) || True then f(-x) from (x,) ) g = ( || x 0 then self._a -x || self._a - 0 from (x,)) Is this an actual language? It looks sort of like CSP. Python with native parallelism, m. The

Re: A replacement for lambda

2005-07-30 Thread Reinhold Birkenfeld
Stefan Rank wrote: on 30.07.2005 10:20 Paolino said the following: why (x**2 with(x))(x**3 with(x)) is not taken in consideration? If 'with' must be there (and substitue 'lambda:') then at least the syntax is clear.IMO Ruby syntax is also clear. I am sorry if this has already been

Re: A replacement for lambda

2005-07-30 Thread Seth Nielson
I understand that there are a number of people who wish to remove lambda entirely from the language. Nevertheless, I find it a useful and powerful tool in actual development. Any replacement must support the following: *delayed evaluation*. I need a convenient (def is not always convenient) way

Re: A replacement for lambda

2005-07-30 Thread Paul Rubin
Seth Nielson [EMAIL PROTECTED] writes: Any replacement must support the following: *delayed evaluation*. I need a convenient (def is not always convenient) way of saying, don't do this now. That is why I use lambda. How's this: f{args} (curly braces instead of parens) is the same as

Re: A replacement for lambda

2005-07-30 Thread Bengt Richter
On Fri, 29 Jul 2005 18:07:31 -0400, Mike Meyer [EMAIL PROTECTED] wrote: I know, lambda bashing (and defending) in the group is one of the most popular ways to avoid writing code. However, while staring at some Oz code, I noticed a feature that would seem to make both groups happy - if we can

Re: A replacement for lambda

2005-07-30 Thread Bengt Richter
On Fri, 29 Jul 2005 18:07:31 -0400, Mike Meyer [EMAIL PROTECTED] wrote: I know, lambda bashing (and defending) in the group is one of the most popular ways to avoid writing code. However, while staring at some Oz code, I noticed a feature that would seem to make both groups happy - if we can

Re: A replacement for lambda

2005-07-30 Thread Peter Hansen
Paul Rubin wrote: How's this: f{args} (curly braces instead of parens) is the same as f(lambda: args). Examples: launch_thread{targetfunc(a,b,c)} b = Button{callback=pressed()} # Button remembers callback() sign_of_a = ternary{a 0, -1, 1} I'd consider this an interesting

Re: A replacement for lambda

2005-07-30 Thread Paul Rubin
Peter Hansen [EMAIL PROTECTED] writes: sign_of_a = ternary{a 0, -1, 1} I'd consider this an interesting idea if it weren't for the fact that (at least with the fonts I generally use) I can barely make out the difference between the {} and the () above. Ok, how about an escaped paren:

Re: A replacement for lambda

2005-07-30 Thread Jeff Epler
On Fri, Jul 29, 2005 at 10:14:12PM -0700, Tim Roberts wrote: C++ solves this exact problem quite reasonably by having a greedy tokenizer. Thus, that would always be a left shift operator. To make it less than and a function, insert a space: x**2 with(x) x**3 with(x) Incidentally, I read

Re: A replacement for lambda

2005-07-30 Thread Christopher Subich
Paul Rubin wrote: Christopher Subich [EMAIL PROTECTED] writes: My personal favourite is to replace lambda entirely with an expression comprehension, using and delimeters. But how does that let you get more than one expression into the anonymous function? It doesn't. Functionally, it's

Re: A replacement for lambda

2005-07-30 Thread Christopher Subich
Scott David Daniels wrote: What kind of shenanigans must a parser go through to translate: x**2 with(x)x**3 with(x) this is the comparison of two functions, but it looks like a left- shift on a function until the second with is encountered. Then you need to backtrack to the shift and

Re: A replacement for lambda

2005-07-30 Thread Christopher Subich
Paolino wrote: why (x**2 with(x))(x**3 with(x)) is not taken in consideration? Looks too much like a generator expression for my taste. Also, expr .. syntax could be used with 'for' instead of 'with' if PEP343 poses a problem, whereas (expr for params) is identically a generator expression.

Re: A replacement for lambda

2005-07-30 Thread Christopher Subich
Paddy wrote: Christopher Subich [EMAIL PROTECTED] writes: Basically, I'd rewrite the Python grammar such that: lambda_form ::= expression with parameter_list I do prefer my parameter list to come before the expression. It would remain consistant with simple function definitions.

Re: A replacement for lambda

2005-07-30 Thread Mike Meyer
[EMAIL PROTECTED] (Bengt Richter) writes: On Fri, 29 Jul 2005 18:07:31 -0400, Mike Meyer [EMAIL PROTECTED] wrote: I know, lambda bashing (and defending) in the group is one of the most popular ways to avoid writing code. However, while staring at some Oz code, I noticed a feature that would seem

Re: A replacement for lambda

2005-07-29 Thread Christopher Subich
Mike Meyer wrote: My choice for the non-name token is @. It's already got magic powers, so we'll give it more rather than introducing another token with magic powers, as the lesser of two evils. Doesn't work. The crux of your change isn't introducing a meaning to @ (and honestly, I prefer

Re: A replacement for lambda

2005-07-29 Thread Paul Rubin
Christopher Subich [EMAIL PROTECTED] writes: My personal favourite is to replace lambda entirely with an expression comprehension, using and delimeters. But how does that let you get more than one expression into the anonymous function? -- http://mail.python.org/mailman/listinfo/python-list

Re: A replacement for lambda

2005-07-29 Thread Scott David Daniels
Christopher Subich wrote: g = x**2 with (x) g(1) == 1 Basically, I'd rewrite the Python grammar such that: lambda_form ::= expression with parameter_list Biggest change is that parameter_list is no longer optional, so zero-argument expr-comps would be written as expr with (), which

Re: A replacement for lambda

2005-07-29 Thread James Richards
On 2005-07-30, Scott David Daniels [EMAIL PROTECTED] wrote: Christopher Subich wrote: g = x**2 with (x) g(1) == 1 Basically, I'd rewrite the Python grammar such that: lambda_form ::= expression with parameter_list Biggest change is that parameter_list is no longer optional, so