closures and dynamic binding

Terry Reedy tjreedy at udel.edu
Fri Oct 3 18:46:54 EDT 2008


Hrvoje Niksic wrote:
> greg <greg at cosc.canterbury.ac.nz> writes:

> I don't think it has anything to do with variable leaking out of the
> loop.  Common Lisp doesn't leak the loop variable, and it behaves the
> same.  It is more a result of the different views of what iteration
> is.  Common Lisp and Python define iteration in terms of repeating the
> same instructions over and over, not different from what C does, in
> which case it makes sense to reuse the same environment for all loop
> passes.  (Python's language ref defines that a standard "assignment"
> is done for each new iteration.)  In contrast, Scheme regards
> iteration as a special case of recursion, 

Whereas I regard iteration as 'within-namespace recursion' ;-)
which amounts to what Python, etc, do.




More information about the Python-list mailing list