3 ms·
Black and White are two states where you should never use negation, and hence bool is not the right choice for self-evident code. I.e., you should never see th
by WalterBright 3y ago
Black and White are two states where you should never use negation, and hence bool is not the right choice for self-evident code.
I.e., you should never see this in code:
if (piece != Black)
- codr7 3y agoWhy? If there are only two states, and provably will never be more; it's either or.
- WalterBright 3y agoBecause negation is a cognitive problem people have. The other problem happens when a third state is added - it becomes very hard to find all the dependencies that need updating. A classic case of this: if (!Windows) ... do something for Posix ...
- codr7 3y agoYes, and I agree in most cases. But the previous example is not one of those.