Unfortunately I had completely ignored PEP634 until now (thinking it was something about regular expressions or something), and now finally I see that it is something that it is a subject I would really love. I’m trying to find the discussion on this, because otherwise I’ll probably just rehash things that have been said already, but I can’t find it:-(
So I’ll just ask here, and if no-one answers I’ll just shut up (and won’t be offended:-)
First: I love PEP634 and the functionality it provides, and how it provides it.
But: there is one eyesore that bothers me and that is that when you’re reading a case you have to make a distinction between capture_pattern and all the other patterns. The syntax for capture_pattern also needs an explicit !"_" in its definition because otherwise the parser would also fall foul of that eyesore.
all the other places in python where you have to use a NAME generally don’t accept any other form of “expression-lookalike” constructs, so these don’t cause this confusion while reading.
PEP642 provides a solution to this with an explicit as keyword in the capture_pattern, but it solves a whole lot of other things as well.
Has there been any discussion on requiring the as keyword in a capture_pattern? And why was it rejected?
Here are some of the discussion threads I found. Unfortunately I can only post 2 links at a time, so I will have to post them as paths to be appended to https://mail.python.org/archives/list/.
Thoughts on PEP 634 (Structural Pattern Matching) python-dev@python.org/thread/5JP7GT73BSNK4R7FX6WXLT5KAXFKLPAH/
Concerns about PEP 634 python-dev@python.org/thread/E3AMOIB3GKYAGN6IVSLEEKVP4VUEC2V3/
Pep 653: Precise Semantics for Pattern Matching python-dev@python.org/thread/O4I345VHIQUXPDJWPDA54RWVXMYEEBRM/#EXJ6THG6WK2RRXFLCRSY7MRBBKOSRYID
SC 2020 recommendation for PEP 634 python-dev@python.org/thread/YEZKWYP2Z74KL7FAP7TNZV5QGQEWN3R5/
Extrapolating PEP 634: The walrus was waiting for patmat all along python-ideas@python.org/thread/P2JVICNTXT5WEHGVLBGZASKBOC2CNSVF/
PEP 634-636: Mapping patterns and extra keys python-ideas@python.org/thread/KVWH4XRQSFHKB7BO4BSAAYKJMOHDR6BR/