Jussi Piitulainen <jpiit...@ling.helsinki.fi> writes: > I don't actually know for sure what the most correct terminology is, > but I like to think that a closure is a procedure (function) closed in > the environment (namespace) where it was created, so even when it is > called from another environment, it uses the one where it was born.
I usually say that a closure is a package, containing a function with some additional data it needs. The data usually is in the form of name bindings. On the other hand, an object (instance) is a package containg data, with one of more functions that work on this data. So an object is more or less the dual of a closure, and in many cases they can be used for the same purpose. In most programming languages the difference is that closures can be called directly, whereas an object needs to be used with a method call to do the same (this makes Java so ugly in this area). In Python, however, you can define the __call__ method and with this they become almost identical in behaviour. -- Piet van Oostrum <p...@vanoostrum.org> WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list