2 ms·
Why have both switch and match statements?
by tayistay 4y ago
Why have both switch and match statements?
- ddevault 4y agoGood question. The answer is that Hare does not have real pattern matching as you may understand it. The switch statement switches on values, and the match statement switches on types. Merging these faces two problems: one is that the grammar does not support types and values appearing in the same place, and the other is that it would imply either dependent types or a hack similar to them, which we're not really interested in. But I can see that on the surface, the distinction appears a bit arbitrary.