Re: Replacement for lambda - 'def' as an expression?

2005-09-07 Thread Tom Anderson
On Tue, 6 Sep 2005, talin at acm dot org wrote: > add = def( a, b ): > return a + b +1 This is so obviously the right syntax for closures in python that i really can't believe we're still arguing about it. > What about passing an anonymous function as an argument, which is the > most common

Re: Replacement for lambda - 'def' as an expression?

2005-09-07 Thread Paul Rubin
Simo Melenius <[EMAIL PROTECTED]> writes: > But if you could do anonymous blocks, you could just write something > like: > > def generate_randomizer (n, m): > return def (x): > return pow (x, n, m) Yes, as it stands you can already say: def generate_randomizer(n, m): return l

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Simo Melenius
Paul Rubin writes: > Sybren Stuvel <[EMAIL PROTECTED]> writes: > > An example: > > > > def generate_randomizer(n, m): > > randomizer = def(x): > > return x ** n % m > > > > return randomizer > > You're a little bit confused; "name" doesn't necessarily

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Paul Rubin
"Terry Reedy" <[EMAIL PROTECTED]> writes: > Are you claiming that including a reference to the more humanly readable > representation of a function (its source code) somehow detracts from the > beauty of the function concept? Huh? Anonymous functions mean you can use functions as values by spel

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Robert Kern
talin at acm dot org wrote: > I like the decorator idea. Unfortunately, the version of Python I am > using is pre-decorator, and there are various issues involved in > upgrading on Mac OS X (due to the built-in Python 2.3 being used by the > OS itself.) I'll have to look into how to upgrade without

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread talin at acm dot org
I like the decorator idea. Unfortunately, the version of Python I am using is pre-decorator, and there are various issues involved in upgrading on Mac OS X (due to the built-in Python 2.3 being used by the OS itself.) I'll have to look into how to upgrade without breaking too much... Some further

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Sybren Stuvel
Terry Reedy enlightened us with: > Are you claiming that including a reference to the more humanly readable > representation of a function (its source code) somehow detracts from the > beauty of the function concept? Nope. > Or are you claiming that binding a function to a name rather than > so

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Sybren Stuvel
Paul Rubin enlightened us with: > You're a little bit confused; "name" doesn't necessarily mean > "persistent name". Wonderful. Another feature added to Python (that is: the Python version in my mind ;-) without the need to add any features to Python (that is: the real Python) Thanks! Sybren --

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Terry Reedy
"Sybren Stuvel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > talin at acm dot org enlightened us with: >> I'd be sad to see the notion of "anonymous functions" go Though it is as yet unclear as to what may come in compensation. > Same here. I think it's a beautyful concept Are

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Terry Reedy
"talin at acm dot org" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Of course, one can always create a named function. But there are a lot > of cases, such as multimethods / generics and other scenarios where > functions are treated as data, where you have a whole lot of function

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread D H
talin at acm dot org wrote: > I've been reading about how "lambda" is going away in Python 3000 (or See the page built from earlier threads about this: http://wiki.python.org/moin/AlternateLambdaSyntax Your syntax is the same used in boo: http://boo.codehaus.org/Closures -- http://mail.python.or

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Paul Rubin
Sybren Stuvel <[EMAIL PROTECTED]> writes: > An example: > > def generate_randomizer(n, m): > randomizer = def(x): > return x ** n % m > > return randomizer You're a little bit confused; "name" doesn't necessarily mean "persistent name". You could write the above as: def gener

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Sybren Stuvel
Leif K-Brooks enlightened us with: >> It also allows for dynamic function creation in cases where a name >> would not be available. > > What cases are those? An example: def generate_randomizer(n, m): randomizer = def(x): return x ** n % m return randomizer Sybren -- The proble

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Leif K-Brooks
Sybren Stuvel wrote: > It also allows for dynamic function creation in cases where a name > would not be available. What cases are those? -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Rocco Moretti
[EMAIL PROTECTED] wrote: > On Tue, 06 Sep 2005 12:19:21 +0200 > Torsten Bronger wrote: > > >>"talin at acm dot org" <[EMAIL PROTECTED]> writes: >> >>>Anyway, here's an example, then, of how 'def' could be used: >>> >>>add = def( a, b ): >>> return a + b >> >>I'm really not an expert in function

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Sybren Stuvel
talin at acm dot org enlightened us with: > I'd be sad to see the notion of "anonymous functions" go Same here. I think it's a beautyful concept, and very powerful. It also allows for dynamic function creation in cases where a name would not be available. > What about passing an anonymous functio

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread en.karpachov
On Tue, 06 Sep 2005 12:19:21 +0200 Torsten Bronger wrote: > "talin at acm dot org" <[EMAIL PROTECTED]> writes: > > Anyway, here's an example, then, of how 'def' could be used: > > > > add = def( a, b ): > >return a + b > > I'm really not an expert in functional programming, so I wonder > what

Re: Replacement for lambda - 'def' as an expression?

2005-09-06 Thread Torsten Bronger
Hallöchen! "talin at acm dot org" <[EMAIL PROTECTED]> writes: > [...] > > Anyway, here's an example, then, of how 'def' could be used: > > add = def( a, b ): >return a + b I'm really not an expert in functional programming, so I wonder what's the difference between "add = def" (assumed that

Replacement for lambda - 'def' as an expression?

2005-09-06 Thread talin at acm dot org
I've been reading about how "lambda" is going away in Python 3000 (or at least, that's the stated intent), and while I agree for the most part with the reasoning, at the same time I'd be sad to see the notion of "anonymous functions" go - partly because I use them all the time. Of course, one can