|
|
Log in / Subscribe / Register

"Structural pattern matching" for Python, part 2

"Structural pattern matching" for Python, part 2

Posted Sep 2, 2020 21:25 UTC (Wed) by nybble41 (subscriber, #55106)
In reply to: "Structural pattern matching" for Python, part 2 by mb
Parent article: "Structural pattern matching" for Python, part 2

Maybe I just lack a properly Pythonic mindset, but the most bizarre part of this proposal to me is the fact that the names are *assigned* rather than *bound* within the lexical scope of the match arm. Every other language I know of with pattern matching creates lexical bindings for match variables rather than allowing the match itself to have side effects on existing variables. If the match placeholders were bound lexically then it would make perfect sense that they can't be qualified. As implicit assignments, however, the restriction does seem a bit arbitrary. At the moment Python appears to lack a concept of lexical block scope. Perhaps that deficiency should be rectified before moving on more advanced features like pattern matching.


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds