2 ms·
> I don't see any value in trying to quibble about whether it's a bug in the caller or the callee. Right, neither do I - like I said, "that's an issue for the
by scubbo 3y ago
> I don't see any value in trying to quibble about whether it's a bug in the caller or the callee.
Right, neither do I - like I said, "that's an issue for the _overall system_ of a cache which stores T.". The bug is that a given type (None) has different meanings to different components of the system, and this bug only arises _because_ "One function's return value is [being passed, directly, without any interpretation, as ] another function's parameter". If the type signatures were changed so that interpretation was required - so that "the answer is None" could be distinguished from "I don't have an answer" - then the bug in the overall system goes away.
- lmm 3y ago> this bug only arises _because_ "One function's return value is [being passed, directly, without any interpretation, as ] another function's parameter". Which is the normal way of programming. If you can't safely compose functions without adding an extra layer of interpretation between them, programming becomes much harder. > If the type signatures were changed so that interpretation was required - so that "the answer is None" could be distinguished from "I don't have an answer" - then the bug in the overall system goes away. Which is something that using sum types rather than union types achieves by default. Wherever you want to localise the problem, union types add a big, easy class of ways to shoot yourself in the foot that just aren't there if you use sum types.