3 ms·
I've seen this complaint that using bools directly causes problems (I agree) but the solution is trivial, either turn those booleans into type-safe distinct val
by throwaway_pdp09 6y ago
I've seen this complaint that using bools directly causes problems (I agree) but the solution is trivial, either turn those booleans into type-safe distinct values:
flushability {FlushData, DontFlushData};
CloseFile(file f, flushability AndFlushToDisk);
or roll the boolean flag into the function name:
CloseFile(file f, bool AndFlushToDisk);
becomes:
CloseFile(file f, bool AndFlushToDisk); // the original, occasionally still needed...
// ...but add, and recommend instead
CloseFileAndFlush(file f);
CloseFile(file f); // does not flush; name does not claim it does
Why is this so difficult?