|
|
|
|
|
by sillysaurusx
2179 days ago
|
|
I have a visceral dislike of pattern matching. Lisp shows just how much people will abuse it in real-world production codebases. It becomes impossible to understand even simple logic without comments. I’d link to some examples, but I’m on mobile; suffice to say, pull up the emacs codebase and read through some of the more advanced modules like edebug.el. I’m not certain that one uses pattern matching, but it’s a perfect example of “this codebase cannot be understood without extensive study of language features.” You may argue that I am simply not versed enough in pattern matching. “You should study harder.” I would argue that simplicity is worth striving for. I hope this PEP never moves beyond draft. It’s also shocking that most people here seem to be tacitly supporting this, or happy about it. Yes, it’s cool. Yes, it might simplify a few cases. But it will also give birth to codebases that you can’t read in about, say, 5 years. And then you’ll have a bright line between people in the camp of “This is perfectly readable; it does so and so” and the rest of us regular humans that just want to build reliable systems. And oh yes, it becomes impossible to backport to older python versions. Lovely. |
|
Firstly, even basic list destructuring with destructuring-bind is an improvement over a soup of car/cadar/caddr/.
Suppose we are in a compiler and would like to look for expressions of he pattern:
in order to apply DeMorgan's and rewrite them to I would rather have a nice pattern matching case like this: than: Even if a fail-safe version of destructuring-bind is used to validate and get the basic shape, it's still tedious: I don't have a pattern matcher in TXR Lisp. That is such a problem that it's holding up compiler work! Because having to write grotty code just to recognize patterns and pull out pieces is demotivating. It's not just demotivating as in "I don't feel like doing the gruntwork", but demotivating as in, "I don't want to saddle my project with the technical debt caused by cranking out that kind of code", which will have to be rewritten into pattern matching later.