logoalt Hacker News

hirvi74today at 2:40 PM1 replyview on HN

> Next big language addition will be discriminated unions and even that is really "opt-in" if you want to use it.

I was excited for DU until I saw the most recent implementation reveal.

https://github.com/dotnet/csharplang/blob/main/proposals/uni...

Compared to the beauty of Swift:

https://docs.swift.org/swift-book/documentation/the-swift-pr...


Replies

CharlieDigitaltoday at 2:59 PM

The C# impl is still early and I think what will end up happening is that a lot of the boilerplate will end up being owned by source generators in the long term. C# team has a habit of "make it work, make it better". Whatever v1 gets released is some base capability that v2+ will end up making more terse. I'm happy and OK with that; I'd rather have ugly unions than no unions (yes, I already use OneOf)

show 1 reply