|
|
Subscribe / Log in / New account

Python structural pattern matching morphs again

Python structural pattern matching morphs again

Posted Dec 6, 2020 19:59 UTC (Sun) by ehiggs (subscriber, #90713)
In reply to: Python structural pattern matching morphs again by iustin
Parent article: Python structural pattern matching morphs again

Python lacks the sum types that Haskell and Rust have which make the pattern matching exhaustive. So the usefulness appears to be quite limited.


to post comments

Python structural pattern matching morphs again

Posted Dec 6, 2020 20:47 UTC (Sun) by iustin (subscriber, #102433) [Link]

Well, you could also say that the typing annotations are not enforce, so their usefulness is limited. But I've seen real bugs being found by the type annotations, so just because Python+pattern matching is not Haskell's one, I wouldn't say it's not useful.

At least least, it gives a more succint view on what the author of the code thought/how they saw the code flow should happen, (the same way as type annotations show what they thought of the involved types), so in my book they're very useful.


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