Add one more proposal to the list of extant proposals (and a reference
to the relevant message on the Python-3000 mailing list).
This commit is contained in:
parent
5496d1b4f9
commit
48ff6d0fe8
29
pep-3104.txt
29
pep-3104.txt
|
@ -168,7 +168,7 @@ assignment to a name implies a declaration of a local variable only
|
|||
if it would not shadow a name already bound in an outer scope;
|
||||
otherwise assignment is interpreted as rebinding of the outer name.
|
||||
Ruby's scoping syntax and rules have also been debated at great
|
||||
length, and changes seem likely in Ruby 2.0 [25]_.
|
||||
length, and changes seem likely in Ruby 2.0 [28]_.
|
||||
|
||||
|
||||
Overview of Proposals
|
||||
|
@ -313,12 +313,13 @@ Many spellings have been suggested for such a declaration:
|
|||
- ``using x`` [22]_
|
||||
- ``borrow x`` [22]_
|
||||
- ``reuse x`` [23]_
|
||||
- ``scope f x`` [25]_ (explicitly specify which scope)
|
||||
|
||||
The most commonly discussed choices appear to be ``outer``,
|
||||
``global``, and ``nonlocal``. ``outer`` is already used as both a
|
||||
variable name and an attribute name in the standard library. The
|
||||
word ``global`` has a conflicting meaning, because "global variable"
|
||||
is generally understood to mean a variable with top-level scope [24]_.
|
||||
is generally understood to mean a variable with top-level scope [27]_.
|
||||
In C, the keyword ``extern`` means that a name refers to a variable
|
||||
in a different compilation unit. While ``nonlocal`` is a bit long
|
||||
and less pleasant-sounding than some of the other options, it does
|
||||
|
@ -361,7 +362,7 @@ prepended to an assignment or augmented assignment::
|
|||
nonlocal x = 3
|
||||
|
||||
The above has exactly the same meaning as ``nonlocal x; x = 3``.
|
||||
(Guido supports a similar form of the ``global`` statement [26]_.)
|
||||
(Guido supports a similar form of the ``global`` statement [24]_.)
|
||||
|
||||
On the left side of the shorthand form, only identifiers are allowed,
|
||||
not target expressions like ``x[0]``. Otherwise, all forms of
|
||||
|
@ -384,7 +385,7 @@ Backward Compatibility
|
|||
|
||||
This PEP targets Python 3000, as suggested by Guido [19]_. However,
|
||||
others have noted that some options considered in this PEP may be
|
||||
small enough changes to be feasible in Python 2.x [27]_, in which
|
||||
small enough changes to be feasible in Python 2.x [26]_, in which
|
||||
case this PEP could possibly be moved to be a 2.x series PEP.
|
||||
|
||||
As a (very rough) measure of the impact of introducing a new keyword,
|
||||
|
@ -500,18 +501,22 @@ References
|
|||
.. [23] Alternatives to 'outer' (Jim Jewett)
|
||||
http://mail.python.org/pipermail/python-3000/2006-November/004153.html
|
||||
|
||||
.. [24] Global variable (version 2006-11-01T01:23:16)
|
||||
http://en.wikipedia.org/wiki/Global_variable
|
||||
|
||||
.. [25] Ruby 2.0 block local variable
|
||||
http://redhanded.hobix.com/inspect/ruby20BlockLocalVariable.html
|
||||
|
||||
.. [26] Draft PEP for outer scopes (Guido van Rossum)
|
||||
.. [24] Draft PEP for outer scopes (Guido van Rossum)
|
||||
http://mail.python.org/pipermail/python-3000/2006-November/004166.html
|
||||
|
||||
.. [27] Draft PEP for outer scopes (Nick Coghlan)
|
||||
.. [25] Draft PEP for outer scopes (Talin)
|
||||
http://mail.python.org/pipermail/python-3000/2006-November/004190.html
|
||||
|
||||
.. [26] Draft PEP for outer scopes (Nick Coghlan)
|
||||
http://mail.python.org/pipermail/python-3000/2006-November/004237.html
|
||||
|
||||
.. [27] Global variable (version 2006-11-01T01:23:16)
|
||||
http://en.wikipedia.org/wiki/Global_variable
|
||||
|
||||
.. [28] Ruby 2.0 block local variable
|
||||
http://redhanded.hobix.com/inspect/ruby20BlockLocalVariable.html
|
||||
|
||||
|
||||
Acknowledgements
|
||||
================
|
||||
|
||||
|
|
Loading…
Reference in New Issue