|
|
|
|
|
by loup-vaillant
3874 days ago
|
|
> You can use, for example, elaborate if-else constructs that firstly try to determine type of the value, then check for values. That's dynamic typing. Very different from pattern matching over sum types: with dynamic typing, you can basically forget about most compile time guarantees. Seriously, you sound like, "why bother with Ocaml when JavaScript does the same thing?". I can tell you from first hand experience that they do not feel the same at all. The other classic example, class hierarchies, is also very different from pattern matching —and much more cumbersome. The only language I know of that kinda bridged the two is Scala, with case classes. |
|
No, that's run-time branch selection. Exactly as with pattern matching (`match .. with ..'), except the latter is more convenient.
> Seriously, you sound like, "why bother with Ocaml when JavaScript does the same thing?".
And you really think I consider elaborate constructions a better thing than concise pattern matching?