logoalt Hacker News

pansa202/20/20251 replyview on HN

Yeah, it was added to tick the box for people who ask "does Python have pattern matching?"

If you look at the feature in detail, and especially how it clashes with the rest of the language, it's awful. For example:

https://x.com/brandon_rhodes/status/1360226108399099909


Replies

kqr02/20/2025

To be fair, "The Substitution Principle" (more commonly known as "equational reasoning" in this context) has never been valid in any languages that aren't... Haskell, and maybe Ada? Any expression that can trigger side effects is an unsafe substitution. (The reason such substitutions are safe in Haskell and Ada is that those languages prevent expressions from triggering side effects in the first place.)

show 1 reply