|
|
Log in / Subscribe / Register

An overview of structural pattern matching for Python

An overview of structural pattern matching for Python

Posted May 4, 2022 6:56 UTC (Wed) by epa (subscriber, #39769)
In reply to: An overview of structural pattern matching for Python by tialaramex
Parent article: An overview of structural pattern matching for Python

I don’t think there is any language that can easily add new keywords. You always end up with ugliness like _bool. Perl started out with an explicit & prefix for subroutine calls but soon dropped it because everyone prefers to see a bare word, even though it will make it hard to add new builtin functions or keywords later.

All in all, I favour the approach of adding the new keyword in a new version of the language, and let everyone change their code where it clashes, and if you don’t want to do that then don’t upgrade.

The context-aware parser in Python is great as a way to do a smooth upgrade, but I would still appreciate a warning if I have used keywords like match and case as variable names. I would still want to change them everywhere to avoid confusing humans, even if the parser can cope.

(Stroustrup wrote about how C’s ‘bool’ as a header file #define does not really solve any of the keyword clash problems and it would have been better to just add the keyword properly. Anyone have a link to that?)


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