3 ms·
That's misleading. It will only raise an exception of the actual value is not matched. Haskell generates a compile error before even running if that's something
by aurelianito 8y ago
That's misleading. It will only raise an exception of the actual value is not matched. Haskell generates a compile error before even running if that's something that might happen. It is the old distinction between static and dynamic typing applied to pattern matching.
- da_chicken 8y agoWhen exactly are you expecting Python, an interpreted language, to raise a compiler error?
- jgalt212 8y agoI guess, but I think a possible solution here would be a pylint plugin to show a warning so you don't have to wait for a runtime exception.
- crimsonalucard 8y agoYou can raise the error as soon as the match operator is executed. Even if match has a valid match with the expression, if all the branches aren't evaluated the function can still raise an error. This allows for early catching of logic errors during unit testing and negates the need for additional tests.
- freddie_mercury 8y ago> That's misleading. It's not misleading. It answers the question: there is no compile-time check. The OP didn't have to "wonder" they could have just read the link.