3 ms·
Yeah, but multiple returns are _used for other things_. So they encompass error returns _and other things_. Multiple returns by the way would be product types t
by zbobet2012 3y ago
Yeah, but multiple returns are _used for other things_. So they encompass error returns _and other things_. Multiple returns by the way would be product types that are being automatically unpacked.
One of Go's core missions is to keep the number of concepts users need low. Multiple returns encompass the error use case and others.
- amluto 3y agoSure, 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.