> In languages with pattern matching, you find that they use it to > emulate late binding: depending on the structure of a thing, you > perform different code. In Python, this is more easily done using > methods of the object, which naturally dispatch based on the type of > the object. Method dispatch is a great technique and I was once in the "all case statements are insufficiently object-oriented" camp. But sometimes you need to work with base types or other people's classes without subclassing them, so I find myself writing long if-then-elif statements (most recently for a memory profiler), and case statements would make this code clearer. (Though not nice enough to switch languages, in particular to Prolog.) re: "Classes don't participate that easily in pattern matching" True for many classes and I'll admit my proposal was quarter-baked. Even matching on base types like tuple, list, and dictionary would be plenty interesting. (Especially since they're subclassable.) - Brian
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4