Hello, On Wed, 08 Jul 2020 12:45:09 +1200 Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
> On 8/07/20 5:30 am, Paul Sokolovsky wrote: > > from __future__ import const > > > > FOO: const = 1 > > > > match val: > > case FOO: # obviously matches by constant's value > > This would make it *more* difficult to distinguish constants from > assignment targets when looking at the match statement, unless you > choose names which "look constant-like" somehow. Sure, the talk was about good technical means to distinguish symbolic constants and variables for pattern matching. These technical means alone are no replacement for stylistic conventions which improve readability of the code. In this regard, it's no different than e.g. conventions of naming classes vs variables. > It also has the general problem of const-declarations in Python. > Currently the compiler only has to analyse one module at a time; > this would require it to also look inside imported modules to > determine whether things were declared const. Indeed, adding some "const" at the core language level would give many benefits, which certainly would be utilized by (even simple, as embedded in CPython) compilers. E.g. better inter-module scope resolution and optimization, an example of which you give. In terms of complexity, that would be minor comparing to e.g. introducing a parser with unbound memory usage, as done in https://www.python.org/dev/peps/pep-0617 . > > -- > Greg -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ 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/WV2UA4AKXN5PCDCSTWIUHID25QWZTGMS/ Code of Conduct: http://python.org/psf/codeofconduct/