[Prev][Next][Index][Thread]

Re: Closures



> Bruce Hoult <bruce@hoult.org> writes:
> >What languages have you used previously?  You can do exactly the same 
> >thing in many languages, including Lisp, Scheme, Perl, and I think, 
> >recently, Python.
> 
> No, not in Python (lexically surrounding scopes are accessible but immutable
> for some reason). This is partly because of Python's odd mutation-inducing
> binding dogma, but a real annoyance nonetheless.

I suspect the reason's the same as in Java (where you can do the Java
equiv of closing over variables only if they're "final") - there's an
easy implementation if you copy bindings instead of sharing them, and
you can hide the semantic difference by forbidding assignment.

-- Jeff