Let's Talk About Lambda Functions!

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Mon Jul 29 15:53:07 EDT 2002


Fredrik Lundh <fredrik at pythonware.com> wrote:
>to fix the other "mistake", some needs to come up with a
>really great syntax (and get michael hudson to implement
>it for them ;-).  ideas are welcome.

No great syntax here, but some ideas on why it is difficult syntax-wise (in
the hope that someone can overcome them).

Python uses indentation to denote lexical scope at or above the statement
level, while using parenthesis at the expression level.  It is rather easy
to embed parenthesis inside indentation, but the other way is difficult.

So to allow statements in lambdas, it is either necessary to delimit
statements with some begin/end marker in lieu of indentation, or to come up
with a way to embed indentation scoping inside parenthesis scoping.

Another possibility is to allow only those statements that do not have
further scopes.  For example, print and assert would be allowed but
if/then/else would not.

Huaiyu



More information about the Python-list mailing list