PEP 622 – Structural Pattern Matching
Very interesting. This PEP is still in draft state, but I am interested to see how the community will react. For me, I have a few thoughts:<p>1) This is really close to Erlang&#x2F;Elixir pattern matching and will make fail-early code much easier to write and easier to reason about.<p>2) match&#x2F;case means double indentation, which I see they reasoned about later in the &quot;Rejected ideas&quot;. Might have a negative impact on readability.<p>3) Match is an already used word (as acknowledged by the authors), but I think this could have been a good case for actually using hard syntax. For me, perhaps because I&#x27;m used to it, Elixir&#x27;s &quot;{a, b, c} = {:hello, &quot;world&quot;, 42}&quot; just makes sense.<p>4) I hope there won&#x27;t be a big flame-war debacle like with :=<p>5) And then finally there is the question of: &quot;It&#x27;s cool, but do we really need it? And will it increase the surprise factor?&quot; And here I&#x27;m not sure. And again, this was the concern with the new assignment expression. The assignment expression is legitimately useful in some use cases (no more silly while True), but it might reduce the learnability of Python. Python is often used as an introductory programming language, so the impact would be that curricula need to be adjust or beginner programmers will encounter some surprising code along the road.<p>I can&#x27;t say this is a good or bad proposal, I want to see what other opinions are out there, and what kind of projects out there in the world would really benefit from syntax like this.