logoalt Hacker News

98347598today at 12:24 PM3 repliesview on HN

It's very disappointing that they aren't supporting Rust-style discriminated unions.


Replies

Metasyntactictoday at 8:32 PM

Hi there! One of the C# language designers here, working on unions. We're extremely interested in discriminated unions. A real problem is that there so much interest, with many varying proposals on how best to do them. It's a lot to go through, and we've found some of the best designs layer on standard unions. So we like this ordering to lay the foundation for discriminated unions to built on top of! :)

_old_dude_today at 12:41 PM

In C#, all instances have a class, so there is already a discriminant, the class itself.

In the article, the example with the switch works because it switches on the class of the instance.

show 1 reply
hnthrow0287345today at 12:31 PM

One step at a time