I voted for I don’t want pattern matching.
I dislike the syntax and semantics expressed in PEP 634. I see the match
statement as a DSL contrived to look like Python, and to be used inside of Python, but with very different semantics. When you enter a PEP 634 match
statement, the rules of the language change completely, and code that looks like existing Python code does something surprisingly very different. It also adds unprecedented new rules to Python, e.g. you can replace one expression with another in the exact same spot in your code, and if one has dots and the other doesn’t, the semantics of what the statement expresses changes completely. And it changes to yet a third set of semantics if you replace the expression with a single _
.
I think the bar for adding new syntax to Python at this point in its life should be set very high. The language is already conceptually pretty large, and every new feature means new concepts one must learn if one is to read an arbitrary blob of someone else’s Python code. The bigger the new syntax, the higher the bar should become, and so the bigger payoff the new syntax has to provide. To me, pattern matching doesn’t seem like it’s anywhere near big enough a win to be worth its enormous new conceptual load.
I can see how the PEP authors arrived at this approach, and I believe them when they say they thought long and hard about it and they really think this is the best solution. Therefore, since I dislike this approach so much, I’m pessimistic that anybody could come up with a syntax for pattern matching in Python that I would like. That’s why I voted for I don’t want pattern matching rather than I want pattern matching, but not as defined in those PEPs. It’s not that I’m against the whole concept of pattern matching, but I now believe it’s impossible to add it to Python today in a way that I would want.
I don’t find this result all that surprising; my admittedly-poorly-informed opinion is that pattern matching as a language feature works well in single-assignment languages, but not so well in languages that permit reassignment. Also, it’s such a large feature that it’s better to add it early in the language’s development, before too much of the available syntactic surface area gets used up (if you follow my meaning).
Finally, I’ll reference something I swear I saw one very smart Pythonista say in an interview: “In Python, we don’t build Domain-Specific Languages, we build Domain-Specific Libraries”. Obviously you can’t add “capture patterns” using a library. But forego that feature and suddenly I suspect most of pattern matching’s other features could be replaced by library code. Compare the with-pattern-matching and without-pattern-matching examples in the Motivation section of PEP 635. Already they’re roughly the same number of lines. The without-pattern-matching code is admittedly more complex. But write a small function or two to externalize that complexity, and you should be able to bridge the complexity gap between the two examples.