News for hackers. Stuff that matters.
Re:Pony is an open-source, actor-model, high performance pro... by steveklabnik on Thursday January 14, 2016 @03:57PM (#10904430)
There are two major forms of sum type implementations that I'm aware of: tagged and untagged. What you're describing is a tagged union, for exactly the reason you state: there's an extra field for a discriminant which lets you choose the tag. Untagged unions are C's unions, where there's no discriminant, and you just have to know which type is valid at a given time.

Rust supports tagged unions, but can also optimize them to untagged in certain circumstances. We will probably add some kind of untagged union as well, mostly for FFI, but they're very unsafe, for the above reasons.

Re:Pony is an open-source, actor-model, high performance pro... by vram22 on Thursday January 14, 2016 @06:30PM (#10905654)
Got it, thanks. Interesting about Rust's design goals and tradeoffs.
Re:Pony is an open-source, actor-model, high performance pro... by 0cachecoherency on Friday January 15, 2016 @04:25AM (#10908148)
Similarly, Pony's union (ie sum) type implementation always optimises to untagged, but required "boxing" raw machine-words when they're in a union type.