News for hackers. Stuff that matters.
Re:Official proposal for Type Unions in C# by karmakaze on Wednesday August 07, 2024 @07:48PM (#41186691)
Java can't do the ad-hoc mixing of types from different libraries, which is something I've wanted/needed for some ORM+expressions work I was doing. I really like where C# is going with this. Hopefully it will accelerate continuation of the evolution of Java.

I'm almost of the mind to use F# or C# instead of waiting.

Re:Official proposal for Type Unions in C# by bad_user on Wednesday August 07, 2024 @09:58PM (#41187406)
Those are untagged union types and are less useful than you think.

For one, they don't work for generic code where you want to discriminate. I.e., if you have a generic A or B type, you can't pattern match on it. And it's hard to add restrictions to the generic types such that it would work.

Such types sort of work in TypeScript, but TypeScript also has structural typing, meaning that it's designed for it.