[Python-Dev] terminology for "free variables" in Python
eliben at gmail.com
Fri Sep 10 17:30:35 CEST 2010
> > My intention in this post was to clarify whether I'm misunderstanding
> > something or the term 'free' is indeed used for different things in
> > different places. If this is the latter, IMHO it's an inconsistency, even
> > a small one. When I read the code I saw 'free' I went to the docs only
> > read that 'free' is something else. This was somewhat confusing.
> I'm still not clear if my explanation that globals are a subset of
> free variables got rid of the confusion. The full name for what
> CPython marks as "free" would be "free but not global" but that's too
> much of a mouthful.
Yes, I understand it now. The source code of symtable.c has a long comment
above the SET_SCOPE macro which says, among other things: "An implicit
global is a free variable for which the compiler has found no binding in an
enclosing function scope", which is in tune with what you said.
> Also you're digging awfully deep into the implementation here --
Indeed, it all started when I set to understand how symbol tables are
implemented in CPython. The inconsistency in the usage of "free" confused
me, so I consulted pydev for clarification. I'm no longer confused :-)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev