3 ms·
It's easy enough to do DUs, they are working on it, but they are just syntactic sugar for abstract class/subclass for instance, as an example for this https://
by keithnz 3y ago
It's easy enough to do DUs, they are working on it, but they are just syntactic sugar for abstract class/subclass
for instance, as an example for this https://fsharpforfunandprofit.com/posts/designing-for-correctness/ https://fsharpforfunandprofit.com/posts/designing-for-correc... where a C# solution is suggested and done with DUs in F#, I wrote the equivalent DU solution in C#... https://gist.github.com/keithn/ceeeed5f7eb567e1b2333747065d10dd https://gist.github.com/keithn/ceeeed5f7eb567e1b2333747065d1...
Only thing you don't have is exhaustive checking, which I personally don't think is much of a problem pragmatically.
- runevault 3y agoExhaustive checking and locking down the base type if you don't want anyone else to extend it beyond your choices of subtypes, unless there's a way I don't know about to lock down extending to inside your binary while letting others ask for any types that references it. There's a secondary benefit though if they allow DUs of Structs where you can have it be on the stack as a single value based on the size of the largest subtype that could be incredibly useful when you are worried about performance. Inheritance does not do that.