2 ms·
No mention of physical units? I always find it terribly frustrating when trying to read code that talks about physical dimensions like time and space without a
by wyldfire 11y ago
No mention of physical units? I always find it terribly frustrating when trying to read code that talks about physical dimensions like time and space without any clue as to what we're measuring.
const int timeout = strtol(argv[2], NULL, 10);
send_and_waitfor(&msg, timeout);
When I read this code, should I take for granted that the caller and callee are using the same order of magnitude that's intended?
If instead I see
const int timeout_ms = strtol(argv[2], NULL, 10);
send_and_waitfor(&msg, timeout_ms);
then I can quickly audit whether the inputs and outputs actually preserve the convention.
- Stasis5001 11y agoIf possible, it's much better to handle physical units with the type system. If your timeout is a timedelta class (or duration/difftime/interval etc.), then this whole issue disappears.