full closures

Mattias Engdegård f91-men at nada.kth.se
Thu Feb 28 08:34:07 EST 2002


martin at v.loewis.de (Martin v. Loewis) writes:

>As Zenin points out, Python uses objects to emulate closures, whereas
>Lisp uses closures to emulate objects.

An elegant and symmetric statement, but not true. Lisp has both
classes and closures natively. Neither is necessarily "emulated" in
terms of the other.

Python only has read-only closures, so you either have to use classes
or simulate mutable bindings by using a mutable object as middle-man
instead (typically an array of length 1).

This is not a statement of the relative merits of Python and Lisp;
they have different purposes and differ more than most people think
after reading Norvig's article.




More information about the Python-list mailing list