[Python-ideas] Proposal for function expressions

Paul Moore p.f.moore at gmail.com
Wed Jul 15 10:27:11 CEST 2009

2009/7/15 Carl Johnson <cmjohnson.mailinglist at gmail.com>:
> My suggestion for future would be language extenders is that they try
> to solve a broader problem than just the "how do I make callbacks more
> convenient" problem. Just solving that one problem by itself seems
> unlikely to make it into the language, since it is pure "sugar" and
> Pythoneers have a well justified wariness toward anonymous functions
> (why not just name them and be done with it?). Perhaps someone should
> take a look at the original "with" proposal, or some of the various
> "do" and "block" proposals. One idea I think about sometimes is having
> a more convenient way to do something along the lines of
> metaclass.__prepare__ but for functions…

I agree entirely. There's certainly *something* here worthy of
consideration, otherwise it wouldn't keep coming up. But there's
probably a more general construct (yes, I know, "fully general
anonymous functions" - maybe there's something *else*...?) lurking
underneath all of the proposals, and it's worth waiting until someone
discovers it.

The important principle that George quoted:

2009/7/15 George Sakkis <george.sakkis at gmail.com>:
> Thanks, this was it. The important part is Guido's quote "any solution
> that embeds an indentation-based block in the middle of an expression
> is unacceptable", so it's basically a design judgement, not an
> implementation constraint.

is key here - keep blocks and expressions distinct. Future proposals
should keep that in mind.

Maybe there's value in having a "language design principles" PEP where
pronouncements like this could be recorded, for the benefit of people
proposing new features?


More information about the Python-ideas mailing list