PEP 622: Why the match statement is the correct feature right now (#1502)
This commit is contained in:
parent
6f3434b750
commit
e43a11d86e
18
pep-0622.rst
18
pep-0622.rst
|
@ -1769,6 +1769,24 @@ an expression. Nor do we propose a ``while match`` construct present in some lan
|
||||||
with pattern matching, since although it may be handy, it will likely be used
|
with pattern matching, since although it may be handy, it will likely be used
|
||||||
rarely.
|
rarely.
|
||||||
|
|
||||||
|
Other pattern-based constructions
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
Many other languages supporting pattern-matching use it as a basis for multiple
|
||||||
|
language constructs, including a matching operator, a generalized form
|
||||||
|
of assignment, a filter for loops, a method for synchronizing communication,
|
||||||
|
or specialized if statements. Some of these were mentioned in the discussion
|
||||||
|
of the first draft. Another question asked was why this particular form (joining
|
||||||
|
binding and conditional selection) was chosen while other forms were not.
|
||||||
|
|
||||||
|
Introducing more uses of patterns would be too bold and premature given the
|
||||||
|
experience we have using patterns, and would make this proposal too
|
||||||
|
complicated. The statement as presented provides a form of the feature that
|
||||||
|
is sufficiently general to be useful while being self-contained, and without
|
||||||
|
having a massive impact on the syntax and semantics of the language as a whole.
|
||||||
|
|
||||||
|
After some experience with this feature, the community may have a better
|
||||||
|
feeling for what other uses of pattern matching could be valuable in Python.
|
||||||
|
|
||||||
Algebraic matching of repeated names
|
Algebraic matching of repeated names
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue