3 ms·
> The entire reason Go has multiple return values for functions (such as paths and err in this case) is to avoid having to encode errors in the "real" function
by masklinn 15y ago
> The entire reason Go has multiple return values for functions (such as paths and err in this case) is to avoid having to encode errors in the "real" function result.
That's nonsense, MRVs are tuples (conceptually, Go implemented them with special syntax because... well, it's Go so it could not go with the general principle now could it?), so Go very specifically encodes errors in the function result.
And using a sum type would encode the error in the type, not in the result itself.
- 4ad 15y agoMultiple return values are not tuples, Go doesn't have tuples in the type system.
- masklinn 15y ago> Multiple return values are not tuples Multiple return values are a special case of tuples. Hence the "conceptually" part. > Go doesn't have tuples in the type system. Could you explain how you managed to completely miss the part where I say exactly that?