[Python-Dev] Product iteration
Jeremy Hylton
jeremy@beopen.com
Wed, 26 Jul 2000 14:47:12 -0700 (PDT)
Moshe Zadka writes:
> On Wed, 26 Jul 2000, Guido van Rossum wrote:
>
> > > OK, how's that: inner functions have weak reference to variables in the
> > > same scope
> > >
> > > def f():
> > > x = 1
> > > def g():
> > > pass
> >
> > Insert "print x" in the body of g, and "return g" in the body of f.
>
> What are you trying to do, simulate classes via closures? I don't see any
> reason for this to work.
>
There's not simulation going on. He's just expecting closures to
work. I think that any proposal for changed scoping needs to do
lexical scoping properly, including closures. If it doesn't, I vote
-1.
The argument about finalization is specious. You should not write
code that depends on current finalization semantics to do things like
closing files. It's relying on an implementation-dependent feature
that is not part of the language spec. (Just try it on JPython.)
Jeremy