[Python-Dev] return statements in lambda

Tim Peters tim_one@email.msn.com
Mon, 6 Mar 2000 03:12:06 -0500

> maybe adding an (optional but encouraged) "return"
> to lambda would be an improvement?
>     lambda x: x + 10
> vs.
>     lambda x: return x + 10
> or is this just more confusing...  opinions?

It was an odd complaint to begin with, since Lisp-heads aren't used to using
"return" anyway.  More of a symptom of taking a shallow syntactic approach
to a new (to them) language.

For non-Lisp heads, I think it's more confusing in the end, blurring the
distinction between stmts and expressions ("the body of a lambda must be an
expression" ... "ok, i lied, unless it's a 'return' stmt).  If Guido had it
to do over again, I vote he rejects the original patch <wink>.  Short of
that, would have been better if the lambda arglist required parens, and if
the body were required to be a single return stmt (that would sure end the
"lambda x: print x" FAQ -- few would *expect* "return print x" to work!).

hindsight-is-great<wink>-ly y'rs  - tim