Re: [Python-ideas] Lambda again: Anonymous function definition

On Mon, 31 Mar 2008 08:19:35, Eli Courtwright wrote:
+1 to handling anonymous functions/lambdas the way JavaScript does. It's the only thing I like better about JavaScript than Python. I don't know if I agree about leaving off the return statement, though. -matt

Matt Chisholm wrote:
+1 to handling anonymous functions/lambdas the way JavaScript does. It's the only thing I like better about JavaScript than Python.
Unfortunately, there's no way in Python to have a statement inside of an expression (because statements are delimited by line ends and indentation). Many people have attempted this, none have succeeded. Don't go there, you'll just be opening up old wounds... -- Talin

On Wed, Apr 2, 2008 at 9:49 PM, Talin <talin@acm.org> wrote:
Well what's being proposed is for def f(x, y): return x*x + y*y to be a statement, but for def(x,y): x*x + y*y to be an expression. In other words, anonymous def will behave exactly like lambda does now. This seems doable, though I don't know Python's parsing code well enough to understand how difficult it would be to implement. Of course, we all understand that lambda won't change anytime soon; this is really more of a hypothetical "what if we did this in 10 years if there's ever a Python 4000" discussion. - Eli

Matt Chisholm wrote:
+1 to handling anonymous functions/lambdas the way JavaScript does. It's the only thing I like better about JavaScript than Python.
Unfortunately, there's no way in Python to have a statement inside of an expression (because statements are delimited by line ends and indentation). Many people have attempted this, none have succeeded. Don't go there, you'll just be opening up old wounds... -- Talin

On Wed, Apr 2, 2008 at 9:49 PM, Talin <talin@acm.org> wrote:
Well what's being proposed is for def f(x, y): return x*x + y*y to be a statement, but for def(x,y): x*x + y*y to be an expression. In other words, anonymous def will behave exactly like lambda does now. This seems doable, though I don't know Python's parsing code well enough to understand how difficult it would be to implement. Of course, we all understand that lambda won't change anytime soon; this is really more of a hypothetical "what if we did this in 10 years if there's ever a Python 4000" discussion. - Eli
participants (4)
-
Eli Courtwright
-
Matt Chisholm
-
Tal Einat
-
Talin