On 15/11/20 10:48 pm, Paul Sokolovsky wrote:
[from PEP 635]
Pattern matching is complimentary to the object-oriented paradigm.
BTW, there seems to be a typo here -- I think it's meant to be "complementary".
please explain why you chose to proceed anyway (and apply workarounds), instead of first introducing the concept of constants to the language. (Given that amount of work to implement pattern matching is certainly an order of magnitude larger than to introduce constants)."
That's not certain at all, and moreover it's not just a matter of work, it's a language design issue that would require its own extensive investigation and debate. Members of the intended audience (people very familiar with Python and its technicalities) can be expected to understand this, so the PEP doesn't need to spell it out.
How to support multiple variable scopes in one stack frame is not a rocket science at all. One just need to remember how C did that
We can't just do it "like C does" because C requires variables to be declared and Python doesn't.
The only reasons for not implementing the same solution in Python would be intertia of thought and "but it's not done anywhere else in Python".
No, other reasons include that it would require making unrelated language changes that open various other wormcans.
nobody del'eted local variables behind users' backs either, before somebody started to do that for exception clause variables.
There was a good reason for that having to do with reference cycles. Nobody liked it much, but we didn't really have a choice. There is no such pressing need for special scope rules in match statements.