Pattern Matching, F# vs Erlang -
In ERP, you are encouraged to not match the patterns that do not actually handle you. For example:
Case (1st episode RIM 10) - & gt; {OK, 10} 9 - & gt; {OK, 25} end;
There is a style that is encouraged, with the other possible result, the result is a "badmatch" result, in accordance with the philosophy of "crashing" in Erlang is.
On the other hand, F # will issue an "incomplete pattern matching" in the same F # code, such as.
Question: Why not F # warning effectively, each pattern
. _ - & gt; Failed with "Badmatch"
and what to "allow crash"?
Edit : Two interesting answers so far: either to avoid the bug that probably does not handle all cases of algebraic datatype; Or because of the net platform. What is the default behavior in OCMM, if there is a way to check OSM?
Edit : To delete the wrong people The issue of Erlang Darshan is bad code which is not always to cause accidents. This means the accident means instead of writing the function, so that it can control all possible cases, handle the collar (for example) bad cases which are automatically thrown, for people with Java background, checked it There is a difference between having a language with exceptions, which must be withdrawn with every possible exception, and to keep such a language which is not clearly declared. Are you taking the exceptions.
F # (with pattern matching and other languages, such as Haskell and Okamal) adds a case Which one exception.
The most valuable reason to fully match my thoughts and warnings is that it expands your datatype by making the refactor easier, because the compiler will warn you about the code. Not updated with new case.
On the other hand, there are really cases that should be abandoned, and then it can be annoying that in all cases a catchment is often a bad error message, then it is a trade off. .
In response to your edit, this is also a warning by default in Okmem (and in Haskell-in-house).
Comments
Post a Comment