First class lexical closures

Kay Schluehr kay.schluehr at gmx.net
Sun Oct 14 02:42:32 EDT 2007


On Oct 14, 7:54 am, Jon Harrop <j... at ffconsultancy.com> wrote:
> Just debating somewhere else whether or not Python might be considered a
> functional programming language. Lua, Ruby and Perl all seem to provide
> first class lexical closures.
>
> What is the current state of affairs in Python? Last time I looked they were
> just removing (?!) closures...
>
> --
> Dr Jon D Harrop, Flying Frog Consultancyhttp://www.ffconsultancy.com/products/?u

Python has ( ever had ) first class functions. They can be defined
everywhere within each statement and therefore within other function
definitions. They are lexical closures. Pythons support for
*anonymous* closures is somewhat weak. They are not on equal footing
with named functions and they don't play a generative role in the
language ( there is no single piece of language semantics described by
lambda expressions ). There was some willing to remove them in Python
3.0 alltogether. This decision was withdrawn but their power wasn't
extended either.





More information about the Python-list mailing list