Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What's wrong with match? I've used it quite a bit and it is quite powerful.


The syntax is reusing regular python syntax with completely different effects, so you have to learn 2 syntaxes.

Trying to do simple things like matching the content of a variable will fail if you forget you have to use a dotted path if you want to avoid binding.

Trying to do advanced things such as "match a dict with variable key names and values, but you wish to enforce the number and the types and unpack them in variables" is ridiculously twisted to do, when it's even possible.

I use match/case, but it like the early years of type hints or asyncio: terrible ergonomics, and we know there is a ceiling to how much it can improve.


Its incredibly powerful! One downside is variables captured in the match are lifted to the function level. The lack of block level scoping in the match statement leads to a lot of people shooting themselves in the foot by overwriting a variable that they didn't intend to. On a personal note, I find the 2 levels of indentation to reach the case body to be too much as well... but that's just a personal preference.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: