News for hackers. Stuff that matters.
Re:Algebraic Data Types by theseoafs on Thursday July 31, 2014 @03:07PM (#8116275)
This is sort of a different way of saying the same thing: this is effectively no different from the standard tagged-union approach, with the exact same danger of calling the wrong `get` function and triggering a runtime error that you have in C et al. Don't get me wrong, it's certainly a valid representation of a sum type, but when you hear fans of Haskell and ML talking about how useful sum types are, it's generally because the compiler provides some support to ensure that they're safe and usable.
Re:Algebraic Data Types by dllthomas on Thursday July 31, 2014 @03:28PM (#8116408)
I think we mostly agree.

I would note that when I'm dealing with tagged unions in C, as soon as the operation gets at all complicated (more than maybe 3 lines?) I try to pass it off to another function operating on the internal value which restores safety outside the boilerplate. I agree that support for a true tagged union is ideal, though. (Actually, this might make a good attribute in GCC...)