3 ms·
Sure, and everything people do with sum types can also be done with plain C structs, and has been done like that in decades. But I think that saying that multi
by amluto 4y ago
Sure, and everything people do with sum types can also be done with plain C structs, and has been done like that in decades. But I think that saying that multiple returns (which are a sort of product type) “encompass” the error use case (logically a sum type) is overstating the case a bit. I would accept that returning errors can be achieved without sum types (and obviously is achieved without sum types in practice in the huge amount of code in languages that don’t have sum types).
But I would not personally design a new language without sum types or some other similarly strict solution for the kind of programming that will encounter errors.