Common LISP-style closures with Python

John Nagle nagle at
Fri Feb 10 07:26:04 CET 2012

On 2/3/2012 4:27 PM, Antti J Ylikoski wrote:
> In Python textbooks that I have read, it is usually not mentioned that
> we can very easily program Common LISP-style closures with Python. It
> is done as follows:

    Most dynamic languages have closures.  Even Perl and Javascript
have closures.  Javascript really needs them, because the "callback"
orientation of Javascript means you often need to package up state
and pass it into a callback.  It really has very little to do with
functional programming.

    If you want to see a different style of closure, check out Rust,
Mozilla's new language.  Rust doesn't have the "spaghetti stack"
needed to implement closures, so it has more limited closure
semantics.  It's more like some of the C add-ons for closures,
but sounder.

					John Nagle

More information about the Python-list mailing list