Skip to content

Comment on Pattern matching in Python

Comments

While pattern matching is one of my favorite things about OCaml, I'm not sure this fits well in Python. A big part of Python is trying to keep the language from being all things to all people and accumulating esoteric cruft, especially in the syntax. If I ran the zoo, I would have probably chosen a slightly different subset of features for Python, but I have a lot of respect for Guido's intent.

Also, doing anything by overloading arithmetic operators for a semantically unrelated purpose tends to be pretty disharmonious with the rest of the language. The only exception I can think of is Lua's LPEG (http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html), but that's a specific sub-language that tends to be clearly isolated to grammars; in practice, it's usually as distinct as using * within regular expression strings.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.