4 ms·
Indeed, exhaustive pattern matching is sweet. What is the noddy explanation of how it is achieved, I wonder?
by orra 6y ago
Indeed, exhaustive pattern matching is sweet. What is the noddy explanation of how it is achieved, I wonder?
- Hirrolot 6y agodatatype99 generates a switch expression under the hood, and modern compilers check this switch expression for exhaustiveness.
- DaiPlusPlus 6y agoHow do compilers check for exhaustiveness when the domain is unbound? Or rather: how does one constrain an integer in C? C enums are glorified consts, it’s still legal to do `myenum_t x = 0xFFFF` where 0xFFFF is not a defined value. This is necessary to allow for flags/bitfield enums.