diff options
author | Alyssa Coghlan <ncoghlan@gmail.com> | 2024-10-08 07:52:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-08 07:52:12 (GMT) |
commit | 27390990fa9306e2a797a4eb2bd83c5bfc7cb186 (patch) | |
tree | b103ae76df4d6650724f29645053267d75b4ff95 /Doc/library/dis.rst | |
parent | cc9b9bebb2c09c475cb0f278268cce03c115eaea (diff) | |
download | cpython-27390990fa9306e2a797a4eb2bd83c5bfc7cb186.zip cpython-27390990fa9306e2a797a4eb2bd83c5bfc7cb186.tar.gz cpython-27390990fa9306e2a797a4eb2bd83c5bfc7cb186.tar.bz2 |
gh-70870: Clarify dual usage of 'free variable' (#122545)
The term "free variable" has unfortunately become genuinely
ambiguous over the years (presumably due to the names of
some relevant code object instance attributes).
While we can't eliminate that ambiguity at this late date, we can
at least alert people to the potential ambiguity by describing
both the formal meaning of the term and the common
alternative use as a direct synonym for "closure variable".
---------
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Diffstat (limited to 'Doc/library/dis.rst')
-rw-r--r-- | Doc/library/dis.rst | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index e3919c2..75b84a8 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1434,7 +1434,7 @@ iterations of the loop. slot ``i`` of the "fast locals" storage in this mapping. If the name is not found there, loads it from the cell contained in slot ``i``, similar to :opcode:`LOAD_DEREF`. This is used for loading - free variables in class bodies (which previously used + :term:`closure variables <closure variable>` in class bodies (which previously used :opcode:`!LOAD_CLASSDEREF`) and in :ref:`annotation scopes <annotation-scopes>` within class bodies. @@ -1463,8 +1463,8 @@ iterations of the loop. .. opcode:: COPY_FREE_VARS (n) - Copies the ``n`` free variables from the closure into the frame. - Removes the need for special code on the caller's side when calling + Copies the ``n`` :term:`free (closure) variables <closure variable>` from the closure + into the frame. Removes the need for special code on the caller's side when calling closures. .. versionadded:: 3.11 @@ -1937,10 +1937,10 @@ instructions: .. data:: hasfree - Sequence of bytecodes that access a free variable. 'free' in this - context refers to names in the current scope that are referenced by inner - scopes or names in outer scopes that are referenced from this scope. It does - *not* include references to global or builtin scopes. + Sequence of bytecodes that access a :term:`free (closure) variable <closure variable>`. + 'free' in this context refers to names in the current scope that are + referenced by inner scopes or names in outer scopes that are referenced + from this scope. It does *not* include references to global or builtin scopes. .. data:: hasname |