Hi, I had an idea regarding the pattern matching issue of comparing with a
previous constant variable instead of assigning to a new local variable. I'm
not sure if this has been brought up before but instead of using a symbol with
the case statement what if we used a keyword.
So for example,
x = 2value = 2
match value: case global x: # value == x print("value matches")
case x: # x = value print(f"value captured, {x=}")
print(x) # outputs 2
so by adding a specific keyword (in this example global) before the name, we
could tell the match statement to compare with a constant defined before and
without the keyword it function as normal and capture it to the local variable
x.
Other ideas for the keyword are "const" or "static" but these 2 are more
difficult to recognise since they aren't in other parts of python but the
"global" keyword is already implemented so it would be easy to understand.
Thank you for your work on python and the new pattern matching PEP it's a
feature I can't wait to use.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/47LVKZIMJGPOCJYOTUU5QXW7SOCXZHAW/
Code of Conduct: http://python.org/psf/codeofconduct/