what is a closure?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Mon Dec 18 18:54:10 CET 2000

Mon, 18 Dec 2000 11:30:03 +0000, Steve Horne <sh at ttsoftware.co.uk> pisze:

> In short, for the standard behaviour of a closure, would the value
> of a be bound at the time the lambda is defined, or is some kind
> of reference created.

IMHO reference.

Many languages where function closures are important are functional
languages, which avoid mutable objects at all, so that question does
not exist.

The standard way of passing things in Python (and in many other
languages) is by reference. Otherwise it would not be clear how much
to duplicate, because there is no formal distinction beteween an object
"owning" another object and "referring" to it.

If someone wants to pass by value, perhaps he should redesign the
problem to avoid mutability. Then passing by reference is always safe.

 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
  ^^                      SYGNATURA ZASTĘPCZA

More information about the Python-list mailing list