[Python-3000] A plea for anonymous functions
Fredrik Lundh
fredrik at pythonware.com
Thu Nov 16 09:55:11 CET 2006
Ivan Krstić wrote:
>> Let's do some *hard* stuff, for a change.
>
> I couldn't agree more. The fundamental problem that I see, though, is
> that Guido seems strongly opposed to adding any additional
> metaprogramming features to the language [0], and solving much of the
> hard stuff elegantly and without special-cased, one-off solutions,
> requires these.
>
> LINQ-like features certainly require having first-class code blocks.
I'm not convinced that they do -- you can emulate LINQ today with
generators and iterator tools and good old for-in statements:
http://sayspy.blogspot.com/2006/02/why-python-doesnt-need-something-like.html
but as noted in the comments, what's missing is a way for the container
to do query optimizations based on the *entire* filter expression. if
we can come up with a decent mechanism (*) for that, the existing for-in
block construct is good enough for the rest.
more later.
</F>
*) there are plenty of hacks to address parts of this; everything from
algebra on custom objects (used by various SQL construction kits, RE
construction kits, etc), code that analyzes an expression by passing
special AST-building objects through it (used in PIL's point method, for
example), and code that requires you to pass in the expression as a text
string (or a ready-made "compiler" module AST-tree).
More information about the Python-3000
mailing list