4 ms·
You can emulate sum types with classes and inheritance (N classes inherit from an empty base class), can't you?
by codedokode 1y ago
You can emulate sum types with classes and inheritance (N classes inherit from an empty base class), can't you?
- bestouff 1y agoIt's very clunky
- mastry 1y agoYes, very clunky. One of the big issues with this approach is that switch expressions still require a default branch because there’s no way in C# to express a completely closed set. This makes future changes to the set (sum type) hazardous. They continue to fiddle with design approaches to solve this. See https://github.com/dotnet/csharplang/blob/main/meetings/2025/LDM-2025-07-30.md#union-proposals-overview https://github.com/dotnet/csharplang/blob/main/meetings/2025...