3 ms·
I don't think that is in any way a realistic example. But let's turn it around: consider a codebase where every type is aliases for every use. Any function tha
by Timon3 3y ago
I don't think that is in any way a realistic example.
But let's turn it around: consider a codebase where every type is aliases for every use. Any function that returns an int has it packed in its own type, and if you want to use that type somewhere else, you have to add a new method to turn it into that other type.
Every function returns multiple values, but in slightly different containers. Each container is unpacked slightly differently, has a slightly different memory layout.
Why would the above be easier than a codebase that always uses int and returns tuples?
- JonChesterfield 3y agoFunctions that return types wrapping int instead of raw ints are a good thing. Error codes in particular really should be something enum like and not 32 bits of best of luck. In contrast, having some containers call it size and others call it length is indeed moderately unhelpful.
- Timon3 3y ago> Functions that return types wrapping int instead of raw ints are a good thing. Error codes in particular really should be something enum like and not 32 bits of best of luck. That's not what I described. I was talking about numbers without special meaning, and with types which require manual implementation of any conversion. One function might return a container whose length() function returns a wrapped integer, and a different container with the same function name returns a different wrapper. You can't combine those wrappers without explicitly defining a conversion. That's what inconsistency in return types means. > In contrast, having some containers call it size and others call it length is indeed moderately unhelpful. And now imagine it's not just two options, but literally every container returned by every function being special. That's what it means to be inconsistent. But as you can see in your example - even small bits of inconsistency (1 bit, if you want) are annoying and unhelpful.