From 7367e07598c9df5c79ee1c2ead277b5c538373a2 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Sat, 10 Jun 2017 12:08:12 +0200 Subject: [PATCH] Rename rnd to round in I.1 At first, I assumed that this is "rand" function, not "round" function, and was confused why exactly is it a problem that this returns different values. While it's easy to notice when actually reading the code, this slows down the comprehension, and bad function naming is not point of that particular guideline. --- CppCoreGuidelines.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 3d5dd87..9dd3a94 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -1223,12 +1223,12 @@ Correctness. Assumptions not stated in an interface are easily overlooked and ha Controlling the behavior of a function through a global (namespace scope) variable (a call mode) is implicit and potentially confusing. For example: - int rnd(double d) + int round(double d) { - return (rnd_up) ? ceil(d) : d; // don't: "invisible" dependency + return (round_up) ? ceil(d) : d; // don't: "invisible" dependency } -It will not be obvious to a caller that the meaning of two calls of `rnd(7.2)` might give different results. +It will not be obvious to a caller that the meaning of two calls of `round(7.2)` might give different results. ##### Exception