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

Re: Closures




Jeff Dalton <jeff@aiai.ed.ac.uk> wrote in message
200108091600.MAA21550@life.ai.mit.edu...
> > 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.
>
No we share bindings (in Python) and yes the reason is the dogma <wink>.
OTOH it is also related at the just one way philosophy: if you really
need that you can achieve the same with a first-class class with callable
instances ...

regards, Samuele Pedroni.





Follow-Ups: